home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2018 July / PCgo 07-2018 CD-ROM Germany.iso / nw.pak / Unnamed File 004768.unknown < prev    next >
Encoding:
Text File  |  2015-07-29  |  240.6 KB  |  1,657 lines

  1. WebInspector.ProfileType=function(id,name)
  2. {WebInspector.Object.call(this);this._id=id;this._name=name;this._profiles=[];this._profileBeingRecorded=null;this._nextProfileUid=1;if(!window.opener)
  3. window.addEventListener("unload",this._clearTempStorage.bind(this),false);}
  4. WebInspector.ProfileType.Events={AddProfileHeader:"add-profile-header",ProfileComplete:"profile-complete",RemoveProfileHeader:"remove-profile-header",ViewUpdated:"view-updated"}
  5. WebInspector.ProfileType.prototype={nextProfileUid:function()
  6. {return this._nextProfileUid;},hasTemporaryView:function()
  7. {return false;},fileExtension:function()
  8. {return null;},statusBarItems:function()
  9. {return[];},get buttonTooltip()
  10. {return"";},get id()
  11. {return this._id;},get treeItemTitle()
  12. {return this._name;},get name()
  13. {return this._name;},buttonClicked:function()
  14. {return false;},get description()
  15. {return"";},isInstantProfile:function()
  16. {return false;},isEnabled:function()
  17. {return true;},getProfiles:function()
  18. {function isFinished(profile)
  19. {return this._profileBeingRecorded!==profile;}
  20. return this._profiles.filter(isFinished.bind(this));},decorationElement:function()
  21. {return null;},getProfile:function(uid)
  22. {for(var i=0;i<this._profiles.length;++i){if(this._profiles[i].uid===uid)
  23. return this._profiles[i];}
  24. return null;},loadFromFile:function(file)
  25. {var name=file.name;if(name.endsWith(this.fileExtension()))
  26. name=name.substr(0,name.length-this.fileExtension().length);var profile=this.createProfileLoadedFromFile(name);profile.setFromFile();this.setProfileBeingRecorded(profile);this.addProfile(profile);profile.loadFromFile(file);},createProfileLoadedFromFile:function(title)
  27. {throw new Error("Needs implemented.");},addProfile:function(profile)
  28. {this._profiles.push(profile);this.dispatchEventToListeners(WebInspector.ProfileType.Events.AddProfileHeader,profile);},removeProfile:function(profile)
  29. {var index=this._profiles.indexOf(profile);if(index===-1)
  30. return;this._profiles.splice(index,1);this._disposeProfile(profile);},_clearTempStorage:function()
  31. {for(var i=0;i<this._profiles.length;++i)
  32. this._profiles[i].removeTempFile();},profileBeingRecorded:function()
  33. {return this._profileBeingRecorded;},setProfileBeingRecorded:function(profile)
  34. {if(this._profileBeingRecorded&&this._profileBeingRecorded.target())
  35. WebInspector.targetManager.resumeAllTargets();if(profile&&profile.target())
  36. WebInspector.targetManager.suspendAllTargets();this._profileBeingRecorded=profile;},profileBeingRecordedRemoved:function()
  37. {},_reset:function()
  38. {var profiles=this._profiles.slice(0);for(var i=0;i<profiles.length;++i)
  39. this._disposeProfile(profiles[i]);this._profiles=[];this._nextProfileUid=1;},_disposeProfile:function(profile)
  40. {this.dispatchEventToListeners(WebInspector.ProfileType.Events.RemoveProfileHeader,profile);profile.dispose();if(this._profileBeingRecorded===profile){this.profileBeingRecordedRemoved();this.setProfileBeingRecorded(null);}},__proto__:WebInspector.Object.prototype}
  41. WebInspector.ProfileType.DataDisplayDelegate=function()
  42. {}
  43. WebInspector.ProfileType.DataDisplayDelegate.prototype={showProfile:function(profile){},showObject:function(snapshotObjectId,perspectiveName){}}
  44. WebInspector.ProfileHeader=function(target,profileType,title)
  45. {this._target=target;this._profileType=profileType;this.title=title;this.uid=profileType._nextProfileUid++;this._fromFile=false;}
  46. WebInspector.ProfileHeader.StatusUpdate=function(subtitle,wait)
  47. {this.subtitle=subtitle;this.wait=wait;}
  48. WebInspector.ProfileHeader.Events={UpdateStatus:"UpdateStatus",ProfileReceived:"ProfileReceived"}
  49. WebInspector.ProfileHeader.prototype={target:function()
  50. {return this._target;},profileType:function()
  51. {return this._profileType;},updateStatus:function(subtitle,wait)
  52. {this.dispatchEventToListeners(WebInspector.ProfileHeader.Events.UpdateStatus,new WebInspector.ProfileHeader.StatusUpdate(subtitle,wait));},createSidebarTreeElement:function(dataDisplayDelegate)
  53. {throw new Error("Needs implemented.");},createView:function(dataDisplayDelegate)
  54. {throw new Error("Not implemented.");},removeTempFile:function()
  55. {if(this._tempFile)
  56. this._tempFile.remove();},dispose:function()
  57. {},canSaveToFile:function()
  58. {return false;},saveToFile:function()
  59. {throw new Error("Needs implemented");},loadFromFile:function(file)
  60. {throw new Error("Needs implemented");},fromFile:function()
  61. {return this._fromFile;},setFromFile:function()
  62. {this._fromFile=true;},__proto__:WebInspector.Object.prototype}
  63. WebInspector.ProfilesPanel=function()
  64. {WebInspector.PanelWithSidebarTree.call(this,"profiles");this.registerRequiredCSS("ui/panelEnablerView.css");this.registerRequiredCSS("profiler/heapProfiler.css");this.registerRequiredCSS("profiler/profilesPanel.css");var mainView=new WebInspector.VBox();this.splitView().setMainView(mainView);this.profilesItemTreeElement=new WebInspector.ProfilesSidebarTreeElement(this);this.sidebarTree.appendChild(this.profilesItemTreeElement);this.profileViews=createElement("div");this.profileViews.id="profile-views";this.profileViews.classList.add("vbox");mainView.element.appendChild(this.profileViews);this._statusBarElement=createElementWithClass("div","profiles-status-bar");mainView.element.insertBefore(this._statusBarElement,mainView.element.firstChild);this.panelSidebarElement().classList.add("profiles-sidebar-tree-box");var statusBarContainerLeft=createElementWithClass("div","profiles-status-bar");this.panelSidebarElement().insertBefore(statusBarContainerLeft,this.panelSidebarElement().firstChild);var statusBar=new WebInspector.StatusBar(statusBarContainerLeft);this.recordButton=new WebInspector.StatusBarButton("","record-status-bar-item");this.recordButton.addEventListener("click",this.toggleRecordButton,this);statusBar.appendStatusBarItem(this.recordButton);this.clearResultsButton=new WebInspector.StatusBarButton(WebInspector.UIString("Clear all profiles."),"clear-status-bar-item");this.clearResultsButton.addEventListener("click",this._reset,this);statusBar.appendStatusBarItem(this.clearResultsButton);this._profileTypeStatusBar=new WebInspector.StatusBar(this._statusBarElement);this._profileViewStatusBar=new WebInspector.StatusBar(this._statusBarElement);this._profileGroups={};this._launcherView=new WebInspector.MultiProfileLauncherView(this);this._launcherView.addEventListener(WebInspector.MultiProfileLauncherView.EventTypes.ProfileTypeSelected,this._onProfileTypeSelected,this);this._profileToView=[];this._typeIdToSidebarSection={};var types=WebInspector.ProfileTypeRegistry.instance.profileTypes();for(var i=0;i<types.length;i++)
  65. this._registerProfileType(types[i]);this._launcherView.restoreSelectedProfileType();this.profilesItemTreeElement.select();this._showLauncherView();this._createFileSelectorElement();this.element.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);this._registerShortcuts();WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.SuspendStateChanged,this._onSuspendStateChanged,this);}
  66. WebInspector.ProfilesPanel.prototype={searchableView:function()
  67. {return this.visibleView&&this.visibleView.searchableView?this.visibleView.searchableView():null;},_createFileSelectorElement:function()
  68. {if(this._fileSelectorElement)
  69. this.element.removeChild(this._fileSelectorElement);this._fileSelectorElement=WebInspector.createFileSelectorElement(this._loadFromFile.bind(this));this.element.appendChild(this._fileSelectorElement);},_findProfileTypeByExtension:function(fileName)
  70. {var types=WebInspector.ProfileTypeRegistry.instance.profileTypes();for(var i=0;i<types.length;i++){var type=types[i];var extension=type.fileExtension();if(!extension)
  71. continue;if(fileName.endsWith(type.fileExtension()))
  72. return type;}
  73. return null;},_registerShortcuts:function()
  74. {this.registerShortcuts(WebInspector.ShortcutsScreen.ProfilesPanelShortcuts.StartStopRecording,this.toggleRecordButton.bind(this));},_loadFromFile:function(file)
  75. {this._createFileSelectorElement();var profileType=this._findProfileTypeByExtension(file.name);if(!profileType){var extensions=[];var types=WebInspector.ProfileTypeRegistry.instance.profileTypes();for(var i=0;i<types.length;i++){var extension=types[i].fileExtension();if(!extension||extensions.indexOf(extension)!==-1)
  76. continue;extensions.push(extension);}
  77. WebInspector.console.error(WebInspector.UIString("Can't load file. Only files with extensions '%s' can be loaded.",extensions.join("', '")));return;}
  78. if(!!profileType.profileBeingRecorded()){WebInspector.console.error(WebInspector.UIString("Can't load profile while another profile is recording."));return;}
  79. profileType.loadFromFile(file);},toggleRecordButton:function()
  80. {if(!this.recordButton.enabled())
  81. return true;var type=this._selectedProfileType;var isProfiling=type.buttonClicked();this._updateRecordButton(isProfiling);if(isProfiling){this._launcherView.profileStarted();if(type.hasTemporaryView())
  82. this.showProfile(type.profileBeingRecorded());}else{this._launcherView.profileFinished();}
  83. return true;},_onSuspendStateChanged:function()
  84. {this._updateRecordButton(this.recordButton.toggled());},_updateRecordButton:function(toggled)
  85. {var enable=toggled||!WebInspector.targetManager.allTargetsSuspended();this.recordButton.setEnabled(enable);this.recordButton.setToggled(toggled);if(enable)
  86. this.recordButton.setTitle(this._selectedProfileType?this._selectedProfileType.buttonTooltip:"");else
  87. this.recordButton.setTitle(WebInspector.anotherProfilerActiveLabel());if(this._selectedProfileType)
  88. this._launcherView.updateProfileType(this._selectedProfileType,enable);},_profileBeingRecordedRemoved:function()
  89. {this._updateRecordButton(false);this._launcherView.profileFinished();},_onProfileTypeSelected:function(event)
  90. {this._selectedProfileType=(event.data);this._updateProfileTypeSpecificUI();},_updateProfileTypeSpecificUI:function()
  91. {this._updateRecordButton(this.recordButton.toggled());this._profileTypeStatusBar.removeStatusBarItems();var statusBarItems=this._selectedProfileType.statusBarItems();for(var i=0;i<statusBarItems.length;++i)
  92. this._profileTypeStatusBar.appendStatusBarItem(statusBarItems[i]);},_reset:function()
  93. {WebInspector.Panel.prototype.reset.call(this);var types=WebInspector.ProfileTypeRegistry.instance.profileTypes();for(var i=0;i<types.length;i++)
  94. types[i]._reset();delete this.visibleView;this._profileGroups={};this._updateRecordButton(false);this._launcherView.profileFinished();this.sidebarTree.element.classList.remove("some-expandable");this._launcherView.detach();this.profileViews.removeChildren();this._profileViewStatusBar.removeStatusBarItems();this.removeAllListeners();this.recordButton.setVisible(true);this._profileViewStatusBar.element.classList.remove("hidden");this.clearResultsButton.element.classList.remove("hidden");this.profilesItemTreeElement.select();this._showLauncherView();},_showLauncherView:function()
  95. {this.closeVisibleView();this._profileViewStatusBar.removeStatusBarItems();this._launcherView.show(this.profileViews);this.visibleView=this._launcherView;},_registerProfileType:function(profileType)
  96. {this._launcherView.addProfileType(profileType);var profileTypeSection=new WebInspector.ProfileTypeSidebarSection(this,profileType);this._typeIdToSidebarSection[profileType.id]=profileTypeSection;this.sidebarTree.appendChild(profileTypeSection);profileTypeSection.childrenListElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);function onAddProfileHeader(event)
  97. {this._addProfileHeader((event.data));}
  98. function onRemoveProfileHeader(event)
  99. {this._removeProfileHeader((event.data));}
  100. function profileComplete(event)
  101. {this.showProfile((event.data));}
  102. profileType.addEventListener(WebInspector.ProfileType.Events.ViewUpdated,this._updateProfileTypeSpecificUI,this);profileType.addEventListener(WebInspector.ProfileType.Events.AddProfileHeader,onAddProfileHeader,this);profileType.addEventListener(WebInspector.ProfileType.Events.RemoveProfileHeader,onRemoveProfileHeader,this);profileType.addEventListener(WebInspector.ProfileType.Events.ProfileComplete,profileComplete,this);var profiles=profileType.getProfiles();for(var i=0;i<profiles.length;i++)
  103. this._addProfileHeader(profiles[i]);},_handleContextMenuEvent:function(event)
  104. {var element=event.srcElement;while(element&&!element.treeElement&&element!==this.element)
  105. element=element.parentElement;if(!element)
  106. return;if(element.treeElement&&element.treeElement.handleContextMenuEvent){element.treeElement.handleContextMenuEvent(event,this);return;}
  107. var contextMenu=new WebInspector.ContextMenu(event);if(this.visibleView instanceof WebInspector.HeapSnapshotView){this.visibleView.populateContextMenu(contextMenu,event);}
  108. if(element!==this.element||event.srcElement===this.panelSidebarElement()){contextMenu.appendItem(WebInspector.UIString("Load\u2026"),this._fileSelectorElement.click.bind(this._fileSelectorElement));}
  109. contextMenu.show();},showLoadFromFileDialog:function()
  110. {this._fileSelectorElement.click();},_addProfileHeader:function(profile)
  111. {var profileType=profile.profileType();var typeId=profileType.id;this._typeIdToSidebarSection[typeId].addProfileHeader(profile);if(!this.visibleView||this.visibleView===this._launcherView)
  112. this.showProfile(profile);},_removeProfileHeader:function(profile)
  113. {if(profile.profileType()._profileBeingRecorded===profile)
  114. this._profileBeingRecordedRemoved();var i=this._indexOfViewForProfile(profile);if(i!==-1)
  115. this._profileToView.splice(i,1);var profileType=profile.profileType();var typeId=profileType.id;var sectionIsEmpty=this._typeIdToSidebarSection[typeId].removeProfileHeader(profile);if(sectionIsEmpty){this.profilesItemTreeElement.select();this._showLauncherView();}},showProfile:function(profile)
  116. {if(!profile||(profile.profileType().profileBeingRecorded()===profile)&&!profile.profileType().hasTemporaryView())
  117. return null;var view=this._viewForProfile(profile);if(view===this.visibleView)
  118. return view;this.closeVisibleView();view.show(this.profileViews);view.focus();this.visibleView=view;var profileTypeSection=this._typeIdToSidebarSection[profile.profileType().id];var sidebarElement=profileTypeSection.sidebarElementForProfile(profile);sidebarElement.revealAndSelect();this._profileViewStatusBar.removeStatusBarItems();var statusBarItems=view.statusBarItems();for(var i=0;i<statusBarItems.length;++i)
  119. this._profileViewStatusBar.appendStatusBarItem(statusBarItems[i]);return view;},showObject:function(snapshotObjectId,perspectiveName)
  120. {var heapProfiles=WebInspector.ProfileTypeRegistry.instance.heapSnapshotProfileType.getProfiles();for(var i=0;i<heapProfiles.length;i++){var profile=heapProfiles[i];if(profile.maxJSObjectId>=snapshotObjectId){this.showProfile(profile);var view=this._viewForProfile(profile);view.selectLiveObject(perspectiveName,snapshotObjectId);break;}}},_viewForProfile:function(profile)
  121. {var index=this._indexOfViewForProfile(profile);if(index!==-1)
  122. return this._profileToView[index].view;var view=profile.createView(this);view.element.classList.add("profile-view");this._profileToView.push({profile:profile,view:view});return view;},_indexOfViewForProfile:function(profile)
  123. {for(var i=0;i<this._profileToView.length;i++){if(this._profileToView[i].profile===profile)
  124. return i;}
  125. return-1;},closeVisibleView:function()
  126. {if(this.visibleView)
  127. this.visibleView.detach();delete this.visibleView;},appendApplicableItems:function(event,contextMenu,target)
  128. {if(!(target instanceof WebInspector.RemoteObject))
  129. return;if(WebInspector.inspectorView.currentPanel()!==this)
  130. return;var object=(target);var objectId=object.objectId;if(!objectId)
  131. return;var heapProfiles=WebInspector.ProfileTypeRegistry.instance.heapSnapshotProfileType.getProfiles();if(!heapProfiles.length)
  132. return;function revealInView(viewName)
  133. {object.target().heapProfilerAgent().getHeapObjectId(objectId,didReceiveHeapObjectId.bind(this,viewName));}
  134. function didReceiveHeapObjectId(viewName,error,result)
  135. {if(WebInspector.inspectorView.currentPanel()!==this)
  136. return;if(!error)
  137. this.showObject(result,viewName);}
  138. contextMenu.appendItem(WebInspector.UIString.capitalize("Reveal in Summary ^view"),revealInView.bind(this,"Summary"));},__proto__:WebInspector.PanelWithSidebarTree.prototype}
  139. WebInspector.ProfileTypeSidebarSection=function(dataDisplayDelegate,profileType)
  140. {WebInspector.SidebarSectionTreeElement.call(this,profileType.treeItemTitle,null,true);this._dataDisplayDelegate=dataDisplayDelegate;this._profileTreeElements=[];this._profileGroups={};this.hidden=true;}
  141. WebInspector.ProfileTypeSidebarSection.ProfileGroup=function()
  142. {this.profileSidebarTreeElements=[];this.sidebarTreeElement=null;}
  143. WebInspector.ProfileTypeSidebarSection.prototype={addProfileHeader:function(profile)
  144. {this.hidden=false;var profileType=profile.profileType();var sidebarParent=this;var profileTreeElement=profile.createSidebarTreeElement(this._dataDisplayDelegate);this._profileTreeElements.push(profileTreeElement);if(!profile.fromFile()&&profileType.profileBeingRecorded()!==profile){var profileTitle=profile.title;var group=this._profileGroups[profileTitle];if(!group){group=new WebInspector.ProfileTypeSidebarSection.ProfileGroup();this._profileGroups[profileTitle]=group;}
  145. group.profileSidebarTreeElements.push(profileTreeElement);var groupSize=group.profileSidebarTreeElements.length;if(groupSize===2){group.sidebarTreeElement=new WebInspector.ProfileGroupSidebarTreeElement(this._dataDisplayDelegate,profile.title);var firstProfileTreeElement=group.profileSidebarTreeElements[0];var index=this.children.indexOf(firstProfileTreeElement);this.insertChild(group.sidebarTreeElement,index);var selected=firstProfileTreeElement.selected;this.removeChild(firstProfileTreeElement);group.sidebarTreeElement.appendChild(firstProfileTreeElement);if(selected)
  146. firstProfileTreeElement.revealAndSelect();firstProfileTreeElement.small=true;firstProfileTreeElement.mainTitle=WebInspector.UIString("Run %d",1);this.treeOutline.element.classList.add("some-expandable");}
  147. if(groupSize>=2){sidebarParent=group.sidebarTreeElement;profileTreeElement.small=true;profileTreeElement.mainTitle=WebInspector.UIString("Run %d",groupSize);}}
  148. sidebarParent.appendChild(profileTreeElement);},removeProfileHeader:function(profile)
  149. {var index=this._sidebarElementIndex(profile);if(index===-1)
  150. return false;var profileTreeElement=this._profileTreeElements[index];this._profileTreeElements.splice(index,1);var sidebarParent=this;var group=this._profileGroups[profile.title];if(group){var groupElements=group.profileSidebarTreeElements;groupElements.splice(groupElements.indexOf(profileTreeElement),1);if(groupElements.length===1){var pos=sidebarParent.children.indexOf(group.sidebarTreeElement);this.insertChild(groupElements[0],pos);groupElements[0].small=false;groupElements[0].mainTitle=group.sidebarTreeElement.title;this.removeChild(group.sidebarTreeElement);}
  151. if(groupElements.length!==0)
  152. sidebarParent=group.sidebarTreeElement;}
  153. sidebarParent.removeChild(profileTreeElement);profileTreeElement.dispose();if(this.children.length)
  154. return false;this.hidden=true;return true;},sidebarElementForProfile:function(profile)
  155. {var index=this._sidebarElementIndex(profile);return index===-1?null:this._profileTreeElements[index];},_sidebarElementIndex:function(profile)
  156. {var elements=this._profileTreeElements;for(var i=0;i<elements.length;i++){if(elements[i].profile===profile)
  157. return i;}
  158. return-1;},__proto__:WebInspector.SidebarSectionTreeElement.prototype}
  159. WebInspector.ProfilesPanel.ContextMenuProvider=function()
  160. {}
  161. WebInspector.ProfilesPanel.ContextMenuProvider.prototype={appendApplicableItems:function(event,contextMenu,target)
  162. {WebInspector.ProfilesPanel._instance().appendApplicableItems(event,contextMenu,target);}}
  163. WebInspector.ProfileSidebarTreeElement=function(dataDisplayDelegate,profile,className)
  164. {this._dataDisplayDelegate=dataDisplayDelegate;this.profile=profile;WebInspector.SidebarTreeElement.call(this,className,profile.title,"",profile,false);this.refreshTitles();profile.addEventListener(WebInspector.ProfileHeader.Events.UpdateStatus,this._updateStatus,this);if(profile.canSaveToFile())
  165. this._createSaveLink();else
  166. profile.addEventListener(WebInspector.ProfileHeader.Events.ProfileReceived,this._onProfileReceived,this);}
  167. WebInspector.ProfileSidebarTreeElement.prototype={_createSaveLink:function()
  168. {this._saveLinkElement=this.titleContainer.createChild("span","save-link");this._saveLinkElement.textContent=WebInspector.UIString("Save");this._saveLinkElement.addEventListener("click",this._saveProfile.bind(this),false);},_onProfileReceived:function(event)
  169. {this._createSaveLink();},_updateStatus:function(event)
  170. {var statusUpdate=event.data;if(statusUpdate.subtitle!==null)
  171. this.subtitle=statusUpdate.subtitle;if(typeof statusUpdate.wait==="boolean")
  172. this.wait=statusUpdate.wait;this.refreshTitles();},dispose:function()
  173. {this.profile.removeEventListener(WebInspector.ProfileHeader.Events.UpdateStatus,this._updateStatus,this);this.profile.removeEventListener(WebInspector.ProfileHeader.Events.ProfileReceived,this._onProfileReceived,this);},onselect:function()
  174. {this._dataDisplayDelegate.showProfile(this.profile);return true;},ondelete:function()
  175. {this.profile.profileType().removeProfile(this.profile);return true;},handleContextMenuEvent:function(event,panel)
  176. {var profile=this.profile;var contextMenu=new WebInspector.ContextMenu(event);contextMenu.appendItem(WebInspector.UIString("Load\u2026"),panel._fileSelectorElement.click.bind(panel._fileSelectorElement));if(profile.canSaveToFile())
  177. contextMenu.appendItem(WebInspector.UIString("Save\u2026"),profile.saveToFile.bind(profile));contextMenu.appendItem(WebInspector.UIString("Delete"),this.ondelete.bind(this));contextMenu.show();},_saveProfile:function(event)
  178. {this.profile.saveToFile();},__proto__:WebInspector.SidebarTreeElement.prototype}
  179. WebInspector.ProfileGroupSidebarTreeElement=function(dataDisplayDelegate,title,subtitle)
  180. {WebInspector.SidebarTreeElement.call(this,"profile-group-sidebar-tree-item",title,subtitle,null,true);this._dataDisplayDelegate=dataDisplayDelegate;}
  181. WebInspector.ProfileGroupSidebarTreeElement.prototype={onselect:function()
  182. {var hasChildren=this.children.length>0;if(hasChildren)
  183. this._dataDisplayDelegate.showProfile(this.children[this.children.length-1].profile);return hasChildren;},__proto__:WebInspector.SidebarTreeElement.prototype}
  184. WebInspector.ProfilesSidebarTreeElement=function(panel)
  185. {this._panel=panel;this.small=false;WebInspector.SidebarTreeElement.call(this,"profile-launcher-view-tree-item",WebInspector.UIString("Profiles"),"",null,false);}
  186. WebInspector.ProfilesSidebarTreeElement.prototype={onselect:function()
  187. {this._panel._showLauncherView();return true;},get selectable()
  188. {return true;},__proto__:WebInspector.SidebarTreeElement.prototype}
  189. WebInspector.ProfilesPanel.show=function()
  190. {WebInspector.inspectorView.setCurrentPanel(WebInspector.ProfilesPanel._instance());}
  191. WebInspector.ProfilesPanel._instance=function()
  192. {if(!WebInspector.ProfilesPanel._instanceObject)
  193. WebInspector.ProfilesPanel._instanceObject=new WebInspector.ProfilesPanel();return WebInspector.ProfilesPanel._instanceObject;}
  194. WebInspector.ProfilesPanelFactory=function()
  195. {}
  196. WebInspector.ProfilesPanelFactory.prototype={createPanel:function()
  197. {return WebInspector.ProfilesPanel._instance();}};WebInspector.ProfileDataGridNode=function(profileNode,owningTree,hasChildren)
  198. {this.profileNode=profileNode;WebInspector.DataGridNode.call(this,null,hasChildren);this.tree=owningTree;this.childrenByCallUID={};this.lastComparator=null;this.callUID=profileNode.callUID;this.selfTime=profileNode.selfTime;this.totalTime=profileNode.totalTime;this.functionName=WebInspector.beautifyFunctionName(profileNode.functionName);this._deoptReason=(!profileNode.deoptReason||profileNode.deoptReason==="no reason")?"":profileNode.deoptReason;this.url=profileNode.url;}
  199. WebInspector.ProfileDataGridNode.prototype={createCell:function(columnIdentifier)
  200. {var cell=this._createValueCell(columnIdentifier)||WebInspector.DataGridNode.prototype.createCell.call(this,columnIdentifier);if(columnIdentifier==="self"&&this._searchMatchedSelfColumn)
  201. cell.classList.add("highlight");else if(columnIdentifier==="total"&&this._searchMatchedTotalColumn)
  202. cell.classList.add("highlight");if(columnIdentifier!=="function")
  203. return cell;if(this._deoptReason)
  204. cell.classList.add("not-optimized");if(this._searchMatchedFunctionColumn)
  205. cell.classList.add("highlight");if(this.profileNode.scriptId!=="0"){var lineNumber=this.profileNode.lineNumber?this.profileNode.lineNumber-1:0;var columnNumber=this.profileNode.columnNumber?this.profileNode.columnNumber-1:0;var target=this.tree.profileView.target();var urlElement=this.tree.profileView._linkifier.linkifyScriptLocation(target,this.profileNode.scriptId,this.profileNode.url,lineNumber,columnNumber,"profile-node-file");urlElement.style.maxWidth="75%";cell.insertBefore(urlElement,cell.firstChild);}
  206. return cell;},_createValueCell:function(columnIdentifier)
  207. {if(columnIdentifier!=="self"&&columnIdentifier!=="total")
  208. return null;var cell=createElement("td");cell.className="numeric-column";var div=createElement("div");var valueSpan=createElement("span");valueSpan.textContent=this.data[columnIdentifier];div.appendChild(valueSpan);var percentColumn=columnIdentifier+"-percent";if(percentColumn in this.data){var percentSpan=createElement("span");percentSpan.className="percent-column";percentSpan.textContent=this.data[percentColumn];div.appendChild(percentSpan);div.classList.add("profile-multiple-values");}
  209. cell.appendChild(div);return cell;},buildData:function()
  210. {function formatMilliseconds(time)
  211. {return WebInspector.UIString("%.1f\u2009ms",time);}
  212. function formatPercent(value)
  213. {return WebInspector.UIString("%.2f\u2009%",value);}
  214. var functionName;if(this._deoptReason){var content=createDocumentFragment();var marker=content.createChild("span","profile-warn-marker");marker.title=WebInspector.UIString("Not optimized: %s",this._deoptReason);content.createTextChild(this.functionName);functionName=content;}else{functionName=this.functionName;}
  215. this.data={"function":functionName,"self-percent":formatPercent(this.selfPercent),"self":formatMilliseconds(this.selfTime),"total-percent":formatPercent(this.totalPercent),"total":formatMilliseconds(this.totalTime),};},select:function(supressSelectedEvent)
  216. {WebInspector.DataGridNode.prototype.select.call(this,supressSelectedEvent);this.tree.profileView._dataGridNodeSelected(this);},deselect:function(supressDeselectedEvent)
  217. {WebInspector.DataGridNode.prototype.deselect.call(this,supressDeselectedEvent);this.tree.profileView._dataGridNodeDeselected(this);},sort:function(comparator,force)
  218. {var gridNodeGroups=[[this]];for(var gridNodeGroupIndex=0;gridNodeGroupIndex<gridNodeGroups.length;++gridNodeGroupIndex){var gridNodes=gridNodeGroups[gridNodeGroupIndex];var count=gridNodes.length;for(var index=0;index<count;++index){var gridNode=gridNodes[index];if(!force&&(!gridNode.expanded||gridNode.lastComparator===comparator)){if(gridNode.children.length)
  219. gridNode.shouldRefreshChildren=true;continue;}
  220. gridNode.lastComparator=comparator;var children=gridNode.children;var childCount=children.length;if(childCount){children.sort(comparator);for(var childIndex=0;childIndex<childCount;++childIndex)
  221. children[childIndex].recalculateSiblings(childIndex);gridNodeGroups.push(children);}}}},insertChild:function(profileDataGridNode,index)
  222. {WebInspector.DataGridNode.prototype.insertChild.call(this,profileDataGridNode,index);this.childrenByCallUID[profileDataGridNode.callUID]=(profileDataGridNode);},removeChild:function(profileDataGridNode)
  223. {WebInspector.DataGridNode.prototype.removeChild.call(this,profileDataGridNode);delete this.childrenByCallUID[(profileDataGridNode).callUID];},removeChildren:function()
  224. {WebInspector.DataGridNode.prototype.removeChildren.call(this);this.childrenByCallUID={};},findChild:function(node)
  225. {if(!node)
  226. return null;return this.childrenByCallUID[node.callUID];},get selfPercent()
  227. {return this.selfTime/this.tree.totalTime*100.0;},get totalPercent()
  228. {return this.totalTime/this.tree.totalTime*100.0;},populate:function()
  229. {WebInspector.ProfileDataGridNode.populate(this);},populateChildren:function()
  230. {},save:function()
  231. {if(this._savedChildren)
  232. return;this._savedSelfTime=this.selfTime;this._savedTotalTime=this.totalTime;this._savedChildren=this.children.slice();},restore:function()
  233. {if(!this._savedChildren)
  234. return;this.selfTime=this._savedSelfTime;this.totalTime=this._savedTotalTime;this.removeChildren();var children=this._savedChildren;var count=children.length;for(var index=0;index<count;++index){children[index].restore();this.appendChild(children[index]);}},merge:function(child,shouldAbsorb)
  235. {WebInspector.ProfileDataGridNode.merge(this,child,shouldAbsorb);},__proto__:WebInspector.DataGridNode.prototype}
  236. WebInspector.ProfileDataGridNode.merge=function(container,child,shouldAbsorb)
  237. {container.selfTime+=child.selfTime;if(!shouldAbsorb)
  238. container.totalTime+=child.totalTime;var children=container.children.slice();container.removeChildren();var count=children.length;for(var index=0;index<count;++index){if(!shouldAbsorb||children[index]!==child)
  239. container.appendChild(children[index]);}
  240. children=child.children.slice();count=children.length;for(var index=0;index<count;++index){var orphanedChild=children[index];var existingChild=container.childrenByCallUID[orphanedChild.callUID];if(existingChild)
  241. existingChild.merge(orphanedChild,false);else
  242. container.appendChild(orphanedChild);}}
  243. WebInspector.ProfileDataGridNode.populate=function(container)
  244. {if(container._populated)
  245. return;container._populated=true;container.populateChildren();var currentComparator=container.tree.lastComparator;if(currentComparator)
  246. container.sort(currentComparator,true);}
  247. WebInspector.ProfileDataGridTree=function(profileView,rootProfileNode)
  248. {this.tree=this;this.children=[];this.profileView=profileView;this.totalTime=rootProfileNode.totalTime;this.lastComparator=null;this.childrenByCallUID={};}
  249. WebInspector.ProfileDataGridTree.prototype={get expanded()
  250. {return true;},appendChild:function(child)
  251. {this.insertChild(child,this.children.length);},insertChild:function(child,index)
  252. {this.children.splice(index,0,child);this.childrenByCallUID[child.callUID]=child;},removeChildren:function()
  253. {this.children=[];this.childrenByCallUID={};},populateChildren:function()
  254. {},findChild:WebInspector.ProfileDataGridNode.prototype.findChild,sort:WebInspector.ProfileDataGridNode.prototype.sort,save:function()
  255. {if(this._savedChildren)
  256. return;this._savedTotalTime=this.totalTime;this._savedChildren=this.children.slice();},restore:function()
  257. {if(!this._savedChildren)
  258. return;this.children=this._savedChildren;this.totalTime=this._savedTotalTime;var children=this.children;var count=children.length;for(var index=0;index<count;++index)
  259. children[index].restore();this._savedChildren=null;},performSearch:function(searchConfig,shouldJump,jumpBackwards)
  260. {this.searchCanceled();var query=searchConfig.query.trim();if(!query.length)
  261. return 0;var greaterThan=(query.startsWith(">"));var lessThan=(query.startsWith("<"));var equalTo=(query.startsWith("=")||((greaterThan||lessThan)&&query.indexOf("=")===1));var percentUnits=(query.endsWith("%"));var millisecondsUnits=(query.length>2&&query.endsWith("ms"));var secondsUnits=(!millisecondsUnits&&query.endsWith("s"));var queryNumber=parseFloat(query);if(greaterThan||lessThan||equalTo){if(equalTo&&(greaterThan||lessThan))
  262. queryNumber=parseFloat(query.substring(2));else
  263. queryNumber=parseFloat(query.substring(1));}
  264. var queryNumberMilliseconds=(secondsUnits?(queryNumber*1000):queryNumber);if(!isNaN(queryNumber)&&!(greaterThan||lessThan))
  265. equalTo=true;var matcher=createPlainTextSearchRegex(query,"i");function matchesQuery(profileDataGridNode)
  266. {delete profileDataGridNode._searchMatchedSelfColumn;delete profileDataGridNode._searchMatchedTotalColumn;delete profileDataGridNode._searchMatchedFunctionColumn;if(percentUnits){if(lessThan){if(profileDataGridNode.selfPercent<queryNumber)
  267. profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.totalPercent<queryNumber)
  268. profileDataGridNode._searchMatchedTotalColumn=true;}else if(greaterThan){if(profileDataGridNode.selfPercent>queryNumber)
  269. profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.totalPercent>queryNumber)
  270. profileDataGridNode._searchMatchedTotalColumn=true;}
  271. if(equalTo){if(profileDataGridNode.selfPercent==queryNumber)
  272. profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.totalPercent==queryNumber)
  273. profileDataGridNode._searchMatchedTotalColumn=true;}}else if(millisecondsUnits||secondsUnits){if(lessThan){if(profileDataGridNode.selfTime<queryNumberMilliseconds)
  274. profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.totalTime<queryNumberMilliseconds)
  275. profileDataGridNode._searchMatchedTotalColumn=true;}else if(greaterThan){if(profileDataGridNode.selfTime>queryNumberMilliseconds)
  276. profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.totalTime>queryNumberMilliseconds)
  277. profileDataGridNode._searchMatchedTotalColumn=true;}
  278. if(equalTo){if(profileDataGridNode.selfTime==queryNumberMilliseconds)
  279. profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.totalTime==queryNumberMilliseconds)
  280. profileDataGridNode._searchMatchedTotalColumn=true;}}
  281. if(profileDataGridNode.functionName.match(matcher)||(profileDataGridNode.url&&profileDataGridNode.url.match(matcher)))
  282. profileDataGridNode._searchMatchedFunctionColumn=true;if(profileDataGridNode._searchMatchedSelfColumn||profileDataGridNode._searchMatchedTotalColumn||profileDataGridNode._searchMatchedFunctionColumn){profileDataGridNode.refresh();return true;}
  283. return false;}
  284. var current=this.children[0];this._searchResults=[];while(current){if(matchesQuery(current))
  285. this._searchResults.push({profileNode:current});current=current.traverseNextNode(false,null,false);}
  286. this._searchResultIndex=jumpBackwards?0:this._searchResults.length-1;return this._searchResults.length;},searchCanceled:function()
  287. {if(this._searchResults){for(var i=0;i<this._searchResults.length;++i){var profileNode=this._searchResults[i].profileNode;delete profileNode._searchMatchedSelfColumn;delete profileNode._searchMatchedTotalColumn;delete profileNode._searchMatchedFunctionColumn;profileNode.refresh();}}
  288. this._searchResults=[];this._searchResultIndex=-1;},jumpToNextSearchResult:function()
  289. {if(!this._searchResults||!this._searchResults.length)
  290. return;this._searchResultIndex=(this._searchResultIndex+1)%this._searchResults.length;this._jumpToSearchResult(this._searchResultIndex);},jumpToPreviousSearchResult:function()
  291. {if(!this._searchResults||!this._searchResults.length)
  292. return;this._searchResultIndex=(this._searchResultIndex-1+this._searchResults.length)%this._searchResults.length;this._jumpToSearchResult(this._searchResultIndex);},currentSearchResultIndex:function()
  293. {return this._searchResultIndex;},_jumpToSearchResult:function(index)
  294. {var searchResult=this._searchResults[index];if(!searchResult)
  295. return;var profileNode=searchResult.profileNode;profileNode.revealAndSelect();}}
  296. WebInspector.ProfileDataGridTree.propertyComparators=[{},{}];WebInspector.ProfileDataGridTree.propertyComparator=function(property,isAscending)
  297. {var comparator=WebInspector.ProfileDataGridTree.propertyComparators[(isAscending?1:0)][property];if(!comparator){if(isAscending){comparator=function(lhs,rhs)
  298. {if(lhs[property]<rhs[property])
  299. return-1;if(lhs[property]>rhs[property])
  300. return 1;return 0;};}else{comparator=function(lhs,rhs)
  301. {if(lhs[property]>rhs[property])
  302. return-1;if(lhs[property]<rhs[property])
  303. return 1;return 0;};}
  304. WebInspector.ProfileDataGridTree.propertyComparators[(isAscending?1:0)][property]=comparator;}
  305. return comparator;};WebInspector.BottomUpProfileDataGridNode=function(profileNode,owningTree)
  306. {WebInspector.ProfileDataGridNode.call(this,profileNode,owningTree,this._willHaveChildren(profileNode));this._remainingNodeInfos=[];}
  307. WebInspector.BottomUpProfileDataGridNode.prototype={_takePropertiesFromProfileDataGridNode:function(profileDataGridNode)
  308. {this.save();this.selfTime=profileDataGridNode.selfTime;this.totalTime=profileDataGridNode.totalTime;},_keepOnlyChild:function(child)
  309. {this.save();this.removeChildren();this.appendChild(child);},_exclude:function(aCallUID)
  310. {if(this._remainingNodeInfos)
  311. this.populate();this.save();var children=this.children;var index=this.children.length;while(index--)
  312. children[index]._exclude(aCallUID);var child=this.childrenByCallUID[aCallUID];if(child)
  313. this.merge(child,true);},restore:function()
  314. {WebInspector.ProfileDataGridNode.prototype.restore.call(this);if(!this.children.length)
  315. this.hasChildren=this._willHaveChildren(this.profileNode);},merge:function(child,shouldAbsorb)
  316. {this.selfTime-=child.selfTime;WebInspector.ProfileDataGridNode.prototype.merge.call(this,child,shouldAbsorb);},populateChildren:function()
  317. {WebInspector.BottomUpProfileDataGridNode._sharedPopulate(this);},_willHaveChildren:function(profileNode)
  318. {return!!(profileNode.parent&&profileNode.parent.parent);},__proto__:WebInspector.ProfileDataGridNode.prototype}
  319. WebInspector.BottomUpProfileDataGridNode._sharedPopulate=function(container)
  320. {var remainingNodeInfos=container._remainingNodeInfos;var count=remainingNodeInfos.length;for(var index=0;index<count;++index){var nodeInfo=remainingNodeInfos[index];var ancestor=nodeInfo.ancestor;var focusNode=nodeInfo.focusNode;var child=container.findChild(ancestor);if(child){var totalTimeAccountedFor=nodeInfo.totalTimeAccountedFor;child.selfTime+=focusNode.selfTime;if(!totalTimeAccountedFor)
  321. child.totalTime+=focusNode.totalTime;}else{child=new WebInspector.BottomUpProfileDataGridNode(ancestor,(container.tree));if(ancestor!==focusNode){child.selfTime=focusNode.selfTime;child.totalTime=focusNode.totalTime;}
  322. container.appendChild(child);}
  323. var parent=ancestor.parent;if(parent&&parent.parent){nodeInfo.ancestor=parent;child._remainingNodeInfos.push(nodeInfo);}}
  324. for(var i=0;i<container.children.length;++i)
  325. container.children[i].buildData();delete container._remainingNodeInfos;}
  326. WebInspector.BottomUpProfileDataGridTree=function(profileView,rootProfileNode)
  327. {WebInspector.ProfileDataGridTree.call(this,profileView,rootProfileNode);var profileNodeUIDs=0;var profileNodeGroups=[[],[rootProfileNode]];var visitedProfileNodesForCallUID={};this._remainingNodeInfos=[];for(var profileNodeGroupIndex=0;profileNodeGroupIndex<profileNodeGroups.length;++profileNodeGroupIndex){var parentProfileNodes=profileNodeGroups[profileNodeGroupIndex];var profileNodes=profileNodeGroups[++profileNodeGroupIndex];var count=profileNodes.length;for(var index=0;index<count;++index){var profileNode=profileNodes[index];if(!profileNode.UID)
  328. profileNode.UID=++profileNodeUIDs;if(profileNode.parent){var visitedNodes=visitedProfileNodesForCallUID[profileNode.callUID];var totalTimeAccountedFor=false;if(!visitedNodes){visitedNodes={};visitedProfileNodesForCallUID[profileNode.callUID]=visitedNodes;}else{var parentCount=parentProfileNodes.length;for(var parentIndex=0;parentIndex<parentCount;++parentIndex){if(visitedNodes[parentProfileNodes[parentIndex].UID]){totalTimeAccountedFor=true;break;}}}
  329. visitedNodes[profileNode.UID]=true;this._remainingNodeInfos.push({ancestor:profileNode,focusNode:profileNode,totalTimeAccountedFor:totalTimeAccountedFor});}
  330. var children=profileNode.children;if(children.length){profileNodeGroups.push(parentProfileNodes.concat([profileNode]));profileNodeGroups.push(children);}}}
  331. WebInspector.ProfileDataGridNode.populate(this);return this;}
  332. WebInspector.BottomUpProfileDataGridTree.prototype={focus:function(profileDataGridNode)
  333. {if(!profileDataGridNode)
  334. return;this.save();var currentNode=profileDataGridNode;var focusNode=profileDataGridNode;while(currentNode.parent&&(currentNode instanceof WebInspector.ProfileDataGridNode)){currentNode._takePropertiesFromProfileDataGridNode(profileDataGridNode);focusNode=currentNode;currentNode=currentNode.parent;if(currentNode instanceof WebInspector.ProfileDataGridNode)
  335. currentNode._keepOnlyChild(focusNode);}
  336. this.children=[focusNode];this.totalTime=profileDataGridNode.totalTime;},exclude:function(profileDataGridNode)
  337. {if(!profileDataGridNode)
  338. return;this.save();var excludedCallUID=profileDataGridNode.callUID;var excludedTopLevelChild=this.childrenByCallUID[excludedCallUID];if(excludedTopLevelChild)
  339. this.children.remove(excludedTopLevelChild);var children=this.children;var count=children.length;for(var index=0;index<count;++index)
  340. children[index]._exclude(excludedCallUID);if(this.lastComparator)
  341. this.sort(this.lastComparator,true);},buildData:function()
  342. {},populateChildren:function()
  343. {WebInspector.BottomUpProfileDataGridNode._sharedPopulate(this);},__proto__:WebInspector.ProfileDataGridTree.prototype};WebInspector.TopDownProfileDataGridNode=function(profileNode,owningTree)
  344. {var hasChildren=!!(profileNode.children&&profileNode.children.length);WebInspector.ProfileDataGridNode.call(this,profileNode,owningTree,hasChildren);this._remainingChildren=profileNode.children;this.buildData();}
  345. WebInspector.TopDownProfileDataGridNode.prototype={populateChildren:function()
  346. {WebInspector.TopDownProfileDataGridNode._sharedPopulate(this);},__proto__:WebInspector.ProfileDataGridNode.prototype}
  347. WebInspector.TopDownProfileDataGridNode._sharedPopulate=function(container)
  348. {var children=container._remainingChildren;var childrenLength=children.length;for(var i=0;i<childrenLength;++i)
  349. container.appendChild(new WebInspector.TopDownProfileDataGridNode(children[i],(container.tree)));container._remainingChildren=null;}
  350. WebInspector.TopDownProfileDataGridNode._excludeRecursively=function(container,aCallUID)
  351. {if(container._remainingChildren)
  352. container.populate();container.save();var children=container.children;var index=container.children.length;while(index--)
  353. WebInspector.TopDownProfileDataGridNode._excludeRecursively(children[index],aCallUID);var child=container.childrenByCallUID[aCallUID];if(child)
  354. WebInspector.ProfileDataGridNode.merge(container,child,true);}
  355. WebInspector.TopDownProfileDataGridTree=function(profileView,rootProfileNode)
  356. {WebInspector.ProfileDataGridTree.call(this,profileView,rootProfileNode);this._remainingChildren=rootProfileNode.children;WebInspector.ProfileDataGridNode.populate(this);}
  357. WebInspector.TopDownProfileDataGridTree.prototype={focus:function(profileDataGridNode)
  358. {if(!profileDataGridNode)
  359. return;this.save();profileDataGridNode.savePosition();this.children=[profileDataGridNode];this.totalTime=profileDataGridNode.totalTime;},exclude:function(profileDataGridNode)
  360. {if(!profileDataGridNode)
  361. return;this.save();WebInspector.TopDownProfileDataGridNode._excludeRecursively(this,profileDataGridNode.callUID);if(this.lastComparator)
  362. this.sort(this.lastComparator,true);},restore:function()
  363. {if(!this._savedChildren)
  364. return;this.children[0].restorePosition();WebInspector.ProfileDataGridTree.prototype.restore.call(this);},populateChildren:function()
  365. {WebInspector.TopDownProfileDataGridNode._sharedPopulate(this);},__proto__:WebInspector.ProfileDataGridTree.prototype};WebInspector.CPUFlameChartDataProvider=function(cpuProfile,target)
  366. {WebInspector.FlameChartDataProvider.call(this);this._cpuProfile=cpuProfile;this._target=target;this._colorGenerator=WebInspector.CPUFlameChartDataProvider.colorGenerator();}
  367. WebInspector.CPUFlameChartDataProvider.prototype={barHeight:function()
  368. {return 15;},textBaseline:function()
  369. {return 4;},textPadding:function()
  370. {return 2;},dividerOffsets:function(startTime,endTime)
  371. {return null;},minimumBoundary:function()
  372. {return this._cpuProfile.profileStartTime;},totalTime:function()
  373. {return this._cpuProfile.profileHead.totalTime;},maxStackDepth:function()
  374. {return this._maxStackDepth;},timelineData:function()
  375. {return this._timelineData||this._calculateTimelineData();},_calculateTimelineData:function()
  376. {function ChartEntry(depth,duration,startTime,selfTime,node)
  377. {this.depth=depth;this.duration=duration;this.startTime=startTime;this.selfTime=selfTime;this.node=node;}
  378. var entries=[];var stack=[];var maxDepth=5;function onOpenFrame()
  379. {stack.push(entries.length);entries.push(null);}
  380. function onCloseFrame(depth,node,startTime,totalTime,selfTime)
  381. {var index=stack.pop();entries[index]=new ChartEntry(depth,totalTime,startTime,selfTime,node);maxDepth=Math.max(maxDepth,depth);}
  382. this._cpuProfile.forEachFrame(onOpenFrame,onCloseFrame);var entryNodes=new Array(entries.length);var entryLevels=new Uint8Array(entries.length);var entryTotalTimes=new Float32Array(entries.length);var entrySelfTimes=new Float32Array(entries.length);var entryStartTimes=new Float64Array(entries.length);var minimumBoundary=this.minimumBoundary();for(var i=0;i<entries.length;++i){var entry=entries[i];entryNodes[i]=entry.node;entryLevels[i]=entry.depth;entryTotalTimes[i]=entry.duration;entryStartTimes[i]=entry.startTime;entrySelfTimes[i]=entry.selfTime;}
  383. this._maxStackDepth=maxDepth;this._timelineData=new WebInspector.FlameChart.TimelineData(entryLevels,entryTotalTimes,entryStartTimes);this._entryNodes=entryNodes;this._entrySelfTimes=entrySelfTimes;return this._timelineData;},_millisecondsToString:function(ms)
  384. {if(ms===0)
  385. return"0";if(ms<1000)
  386. return WebInspector.UIString("%.1f\u2009ms",ms);return Number.secondsToString(ms/1000,true);},prepareHighlightedEntryInfo:function(entryIndex)
  387. {var timelineData=this._timelineData;var node=this._entryNodes[entryIndex];if(!node)
  388. return null;var entryInfo=[];function pushEntryInfoRow(title,text)
  389. {var row={};row.title=title;row.text=text;entryInfo.push(row);}
  390. var name=WebInspector.beautifyFunctionName(node.functionName);pushEntryInfoRow(WebInspector.UIString("Name"),name);var selfTime=this._millisecondsToString(this._entrySelfTimes[entryIndex]);var totalTime=this._millisecondsToString(timelineData.entryTotalTimes[entryIndex]);pushEntryInfoRow(WebInspector.UIString("Self time"),selfTime);pushEntryInfoRow(WebInspector.UIString("Total time"),totalTime);var text=this._target?WebInspector.Linkifier.liveLocationText(this._target,node.scriptId,node.lineNumber,node.columnNumber):node.url;pushEntryInfoRow(WebInspector.UIString("URL"),text);pushEntryInfoRow(WebInspector.UIString("Aggregated self time"),Number.secondsToString(node.selfTime/1000,true));pushEntryInfoRow(WebInspector.UIString("Aggregated total time"),Number.secondsToString(node.totalTime/1000,true));if(node.deoptReason&&node.deoptReason!=="no reason")
  391. pushEntryInfoRow(WebInspector.UIString("Not optimized"),node.deoptReason);return entryInfo;},canJumpToEntry:function(entryIndex)
  392. {return this._entryNodes[entryIndex].scriptId!=="0";},entryTitle:function(entryIndex)
  393. {var node=this._entryNodes[entryIndex];return WebInspector.beautifyFunctionName(node.functionName);},entryFont:function(entryIndex)
  394. {if(!this._font){this._font=(this.barHeight()-4)+"px "+WebInspector.fontFamily();this._boldFont="bold "+this._font;}
  395. var node=this._entryNodes[entryIndex];var reason=node.deoptReason;return(reason&&reason!=="no reason")?this._boldFont:this._font;},entryColor:function(entryIndex)
  396. {var node=this._entryNodes[entryIndex];return this._colorGenerator.colorForID(node.functionName+":"+node.url);},decorateEntry:function(entryIndex,context,text,barX,barY,barWidth,barHeight)
  397. {return false;},forceDecoration:function(entryIndex)
  398. {return false;},highlightTimeRange:function(entryIndex)
  399. {var startTime=this._timelineData.entryStartTimes[entryIndex];return{startTime:startTime,endTime:startTime+this._timelineData.entryTotalTimes[entryIndex]};},paddingLeft:function()
  400. {return 15;},textColor:function(entryIndex)
  401. {return"#333";}}
  402. WebInspector.CPUFlameChartDataProvider.colorGenerator=function()
  403. {if(!WebInspector.CPUFlameChartDataProvider._colorGenerator){var colorGenerator=new WebInspector.FlameChart.ColorGenerator({min:180,max:310,count:7},{min:50,max:80,count:5},{min:80,max:90,count:3});colorGenerator.setColorForID("(idle):","hsl(0, 0%, 94%)");colorGenerator.setColorForID("(program):","hsl(0, 0%, 80%)");colorGenerator.setColorForID("(garbage collector):","hsl(0, 0%, 80%)");WebInspector.CPUFlameChartDataProvider._colorGenerator=colorGenerator;}
  404. return WebInspector.CPUFlameChartDataProvider._colorGenerator;}
  405. WebInspector.CPUProfileFlameChart=function(dataProvider)
  406. {WebInspector.VBox.call(this);this.element.id="cpu-flame-chart";this._overviewPane=new WebInspector.CPUProfileFlameChart.OverviewPane(dataProvider);this._overviewPane.show(this.element);this._mainPane=new WebInspector.FlameChart(dataProvider,this._overviewPane,true);this._mainPane.show(this.element);this._mainPane.addEventListener(WebInspector.FlameChart.Events.EntrySelected,this._onEntrySelected,this);this._overviewPane.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._dataProvider=dataProvider;this._searchResults=[];}
  407. WebInspector.CPUProfileFlameChart.prototype={focus:function()
  408. {this._mainPane.focus();},_onWindowChanged:function(event)
  409. {var windowLeft=event.data.windowTimeLeft;var windowRight=event.data.windowTimeRight;this._mainPane.setWindowTimes(windowLeft,windowRight);},selectRange:function(timeLeft,timeRight)
  410. {this._overviewPane._selectRange(timeLeft,timeRight);},_onEntrySelected:function(event)
  411. {this.dispatchEventToListeners(WebInspector.FlameChart.Events.EntrySelected,event.data);},update:function()
  412. {this._overviewPane.update();this._mainPane.update();},performSearch:function(searchConfig,shouldJump,jumpBackwards)
  413. {var matcher=createPlainTextSearchRegex(searchConfig.query,searchConfig.caseSensitive?"":"i");var selectedEntryIndex=this._searchResultIndex!==-1?this._searchResults[this._searchResultIndex]:-1;this._searchResults=[];var entriesCount=this._dataProvider._entryNodes.length;for(var index=0;index<entriesCount;++index){if(this._dataProvider.entryTitle(index).match(matcher))
  414. this._searchResults.push(index);}
  415. if(this._searchResults.length){this._searchResultIndex=this._searchResults.indexOf(selectedEntryIndex);if(this._searchResultIndex===-1)
  416. this._searchResultIndex=jumpBackwards?this._searchResults.length-1:0;this._mainPane.setSelectedEntry(this._searchResults[this._searchResultIndex]);}else
  417. this.searchCanceled();return this._searchResults.length;},searchCanceled:function()
  418. {this._mainPane.setSelectedEntry(-1);this._searchResults=[];this._searchResultIndex=-1;},jumpToNextSearchResult:function()
  419. {this._searchResultIndex=(this._searchResultIndex+1)%this._searchResults.length;this._mainPane.setSelectedEntry(this._searchResults[this._searchResultIndex]);},jumpToPreviousSearchResult:function()
  420. {this._searchResultIndex=(this._searchResultIndex-1+this._searchResults.length)%this._searchResults.length;this._mainPane.setSelectedEntry(this._searchResults[this._searchResultIndex]);},currentSearchResultIndex:function()
  421. {return this._searchResultIndex;},__proto__:WebInspector.VBox.prototype};WebInspector.CPUProfileFlameChart.OverviewCalculator=function()
  422. {}
  423. WebInspector.CPUProfileFlameChart.OverviewCalculator.prototype={paddingLeft:function()
  424. {return 0;},_updateBoundaries:function(overviewPane)
  425. {this._minimumBoundaries=overviewPane._dataProvider.minimumBoundary();var totalTime=overviewPane._dataProvider.totalTime();this._maximumBoundaries=this._minimumBoundaries+totalTime;this._xScaleFactor=overviewPane._overviewContainer.clientWidth/totalTime;},computePosition:function(time)
  426. {return(time-this._minimumBoundaries)*this._xScaleFactor;},formatTime:function(value,precision)
  427. {return Number.secondsToString((value-this._minimumBoundaries)/1000);},maximumBoundary:function()
  428. {return this._maximumBoundaries;},minimumBoundary:function()
  429. {return this._minimumBoundaries;},zeroTime:function()
  430. {return this._minimumBoundaries;},boundarySpan:function()
  431. {return this._maximumBoundaries-this._minimumBoundaries;}}
  432. WebInspector.CPUProfileFlameChart.OverviewPane=function(dataProvider)
  433. {WebInspector.VBox.call(this);this.element.classList.add("cpu-profile-flame-chart-overview-pane");this._overviewContainer=this.element.createChild("div","cpu-profile-flame-chart-overview-container");this._overviewGrid=new WebInspector.OverviewGrid("cpu-profile-flame-chart");this._overviewGrid.element.classList.add("fill");this._overviewCanvas=this._overviewContainer.createChild("canvas","cpu-profile-flame-chart-overview-canvas");this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.CPUProfileFlameChart.OverviewCalculator();this._dataProvider=dataProvider;this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);}
  434. WebInspector.CPUProfileFlameChart.OverviewPane.prototype={requestWindowTimes:function(windowStartTime,windowEndTime)
  435. {this._selectRange(windowStartTime,windowEndTime);},updateBoxSelection:function(startTime,endTime)
  436. {},_selectRange:function(timeLeft,timeRight)
  437. {var startTime=this._dataProvider.minimumBoundary();var totalTime=this._dataProvider.totalTime();this._overviewGrid.setWindow((timeLeft-startTime)/totalTime,(timeRight-startTime)/totalTime);},_onWindowChanged:function(event)
  438. {var startTime=this._dataProvider.minimumBoundary();var totalTime=this._dataProvider.totalTime();var data={windowTimeLeft:startTime+this._overviewGrid.windowLeft()*totalTime,windowTimeRight:startTime+this._overviewGrid.windowRight()*totalTime};this.dispatchEventToListeners(WebInspector.OverviewGrid.Events.WindowChanged,data);},_timelineData:function()
  439. {return this._dataProvider.timelineData();},onResize:function()
  440. {this._scheduleUpdate();},_scheduleUpdate:function()
  441. {if(this._updateTimerId)
  442. return;this._updateTimerId=this.element.window().requestAnimationFrame(this.update.bind(this));},update:function()
  443. {this._updateTimerId=0;var timelineData=this._timelineData();if(!timelineData)
  444. return;this._resetCanvas(this._overviewContainer.clientWidth,this._overviewContainer.clientHeight-WebInspector.FlameChart.DividersBarHeight);this._overviewCalculator._updateBoundaries(this);this._overviewGrid.updateDividers(this._overviewCalculator);this._drawOverviewCanvas();},_drawOverviewCanvas:function()
  445. {var canvasWidth=this._overviewCanvas.width;var canvasHeight=this._overviewCanvas.height;var drawData=this._calculateDrawData(canvasWidth);var context=this._overviewCanvas.getContext("2d");var ratio=window.devicePixelRatio;var offsetFromBottom=ratio;var lineWidth=1;var yScaleFactor=canvasHeight/(this._dataProvider.maxStackDepth()*1.1);context.lineWidth=lineWidth;context.translate(0.5,0.5);context.strokeStyle="rgba(20,0,0,0.4)";context.fillStyle="rgba(214,225,254,0.8)";context.moveTo(-lineWidth,canvasHeight+lineWidth);context.lineTo(-lineWidth,Math.round(canvasHeight-drawData[0]*yScaleFactor-offsetFromBottom));var value;for(var x=0;x<canvasWidth;++x){value=Math.round(canvasHeight-drawData[x]*yScaleFactor-offsetFromBottom);context.lineTo(x,value);}
  446. context.lineTo(canvasWidth+lineWidth,value);context.lineTo(canvasWidth+lineWidth,canvasHeight+lineWidth);context.fill();context.stroke();context.closePath();},_calculateDrawData:function(width)
  447. {var dataProvider=this._dataProvider;var timelineData=this._timelineData();var entryStartTimes=timelineData.entryStartTimes;var entryTotalTimes=timelineData.entryTotalTimes;var entryLevels=timelineData.entryLevels;var length=entryStartTimes.length;var minimumBoundary=this._dataProvider.minimumBoundary();var drawData=new Uint8Array(width);var scaleFactor=width/dataProvider.totalTime();for(var entryIndex=0;entryIndex<length;++entryIndex){var start=Math.floor((entryStartTimes[entryIndex]-minimumBoundary)*scaleFactor);var finish=Math.floor((entryStartTimes[entryIndex]-minimumBoundary+entryTotalTimes[entryIndex])*scaleFactor);for(var x=start;x<=finish;++x)
  448. drawData[x]=Math.max(drawData[x],entryLevels[entryIndex]+1);}
  449. return drawData;},_resetCanvas:function(width,height)
  450. {var ratio=window.devicePixelRatio;this._overviewCanvas.width=width*ratio;this._overviewCanvas.height=height*ratio;this._overviewCanvas.style.width=width+"px";this._overviewCanvas.style.height=height+"px";},__proto__:WebInspector.VBox.prototype};WebInspector.CPUProfileView=function(profileHeader)
  451. {WebInspector.VBox.call(this);this.element.classList.add("cpu-profile-view");this._searchableView=new WebInspector.SearchableView(this);this._searchableView.show(this.element);this._viewType=WebInspector.settings.createSetting("cpuProfilerView",WebInspector.CPUProfileView._TypeHeavy);var columns=[];columns.push({id:"self",title:WebInspector.UIString("Self"),width:"120px",sort:WebInspector.DataGrid.Order.Descending,sortable:true});columns.push({id:"total",title:WebInspector.UIString("Total"),width:"120px",sortable:true});columns.push({id:"function",title:WebInspector.UIString("Function"),disclosure:true,sortable:true});this.dataGrid=new WebInspector.DataGrid(columns);this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,this._sortProfile,this);this.viewSelectComboBox=new WebInspector.StatusBarComboBox(this._changeView.bind(this));var options={};options[WebInspector.CPUProfileView._TypeFlame]=this.viewSelectComboBox.createOption(WebInspector.UIString("Chart"),"",WebInspector.CPUProfileView._TypeFlame);options[WebInspector.CPUProfileView._TypeHeavy]=this.viewSelectComboBox.createOption(WebInspector.UIString("Heavy (Bottom Up)"),"",WebInspector.CPUProfileView._TypeHeavy);options[WebInspector.CPUProfileView._TypeTree]=this.viewSelectComboBox.createOption(WebInspector.UIString("Tree (Top Down)"),"",WebInspector.CPUProfileView._TypeTree);var optionName=this._viewType.get()||WebInspector.CPUProfileView._TypeFlame;var option=options[optionName]||options[WebInspector.CPUProfileView._TypeFlame];this.viewSelectComboBox.select(option);this.focusButton=new WebInspector.StatusBarButton(WebInspector.UIString("Focus selected function."),"focus-status-bar-item");this.focusButton.setEnabled(false);this.focusButton.addEventListener("click",this._focusClicked,this);this.excludeButton=new WebInspector.StatusBarButton(WebInspector.UIString("Exclude selected function."),"delete-status-bar-item");this.excludeButton.setEnabled(false);this.excludeButton.addEventListener("click",this._excludeClicked,this);this.resetButton=new WebInspector.StatusBarButton(WebInspector.UIString("Restore all functions."),"refresh-status-bar-item");this.resetButton.setVisible(false);this.resetButton.addEventListener("click",this._resetClicked,this);this._profileHeader=profileHeader;this._linkifier=new WebInspector.Linkifier(new WebInspector.Linkifier.DefaultFormatter(30));this.profile=new WebInspector.CPUProfileDataModel(profileHeader._profile||profileHeader.protocolProfile());this._changeView();if(this._flameChart)
  452. this._flameChart.update();}
  453. WebInspector.CPUProfileView._TypeFlame="Flame";WebInspector.CPUProfileView._TypeTree="Tree";WebInspector.CPUProfileView._TypeHeavy="Heavy";WebInspector.CPUProfileView.Searchable=function()
  454. {}
  455. WebInspector.CPUProfileView.Searchable.prototype={jumpToNextSearchResult:function(){},jumpToPreviousSearchResult:function(){},searchCanceled:function(){},performSearch:function(searchConfig,shouldJump,jumpBackwards){},currentSearchResultIndex:function(){}}
  456. WebInspector.CPUProfileView.prototype={focus:function()
  457. {if(this._flameChart)
  458. this._flameChart.focus();else
  459. WebInspector.View.prototype.focus.call(this);},target:function()
  460. {return this._profileHeader.target();},selectRange:function(timeLeft,timeRight)
  461. {if(!this._flameChart)
  462. return;this._flameChart.selectRange(timeLeft,timeRight);},statusBarItems:function()
  463. {return[this.viewSelectComboBox,this.focusButton,this.excludeButton,this.resetButton];},_getBottomUpProfileDataGridTree:function()
  464. {if(!this._bottomUpProfileDataGridTree)
  465. this._bottomUpProfileDataGridTree=new WebInspector.BottomUpProfileDataGridTree(this,(this.profile.profileHead));return this._bottomUpProfileDataGridTree;},_getTopDownProfileDataGridTree:function()
  466. {if(!this._topDownProfileDataGridTree)
  467. this._topDownProfileDataGridTree=new WebInspector.TopDownProfileDataGridTree(this,(this.profile.profileHead));return this._topDownProfileDataGridTree;},willHide:function()
  468. {this._currentSearchResultIndex=-1;},refresh:function()
  469. {var selectedProfileNode=this.dataGrid.selectedNode?this.dataGrid.selectedNode.profileNode:null;this.dataGrid.rootNode().removeChildren();var children=this.profileDataGridTree.children;var count=children.length;for(var index=0;index<count;++index)
  470. this.dataGrid.rootNode().appendChild(children[index]);if(selectedProfileNode)
  471. selectedProfileNode.selected=true;},refreshVisibleData:function()
  472. {var child=this.dataGrid.rootNode().children[0];while(child){child.refresh();child=child.traverseNextNode(false,null,true);}},searchableView:function()
  473. {return this._searchableView;},supportsCaseSensitiveSearch:function()
  474. {return true;},supportsRegexSearch:function()
  475. {return false;},searchCanceled:function()
  476. {this._searchableElement.searchCanceled();},performSearch:function(searchConfig,shouldJump,jumpBackwards)
  477. {var matchesCount=this._searchableElement.performSearch(searchConfig,shouldJump,jumpBackwards);this._searchableView.updateSearchMatchesCount(matchesCount);this._searchableView.updateCurrentMatchIndex(this._searchableElement.currentSearchResultIndex());},jumpToNextSearchResult:function()
  478. {this._searchableElement.jumpToNextSearchResult();this._searchableView.updateCurrentMatchIndex(this._searchableElement.currentSearchResultIndex());},jumpToPreviousSearchResult:function()
  479. {this._searchableElement.jumpToPreviousSearchResult();this._searchableView.updateCurrentMatchIndex(this._searchableElement.currentSearchResultIndex());},_ensureFlameChartCreated:function()
  480. {if(this._flameChart)
  481. return;this._dataProvider=new WebInspector.CPUFlameChartDataProvider(this.profile,this._profileHeader.target());this._flameChart=new WebInspector.CPUProfileFlameChart(this._dataProvider);this._flameChart.addEventListener(WebInspector.FlameChart.Events.EntrySelected,this._onEntrySelected.bind(this));},_onEntrySelected:function(event)
  482. {var entryIndex=event.data;var node=this._dataProvider._entryNodes[entryIndex];var target=this._profileHeader.target();if(!node||!node.scriptId||!target)
  483. return;var script=target.debuggerModel.scriptForId(node.scriptId);if(!script)
  484. return;var location=(script.target().debuggerModel.createRawLocation(script,node.lineNumber,0));WebInspector.Revealer.reveal(WebInspector.debuggerWorkspaceBinding.rawLocationToUILocation(location));},_changeView:function()
  485. {if(!this.profile)
  486. return;this._searchableView.closeSearch();if(this._visibleView)
  487. this._visibleView.detach();this._viewType.set(this.viewSelectComboBox.selectedOption().value);switch(this._viewType.get()){case WebInspector.CPUProfileView._TypeFlame:this._ensureFlameChartCreated();this._visibleView=this._flameChart;this._searchableElement=this._flameChart;break;case WebInspector.CPUProfileView._TypeTree:this.profileDataGridTree=this._getTopDownProfileDataGridTree();this._sortProfile();this._visibleView=this.dataGrid;this._searchableElement=this.profileDataGridTree;break;case WebInspector.CPUProfileView._TypeHeavy:this.profileDataGridTree=this._getBottomUpProfileDataGridTree();this._sortProfile();this._visibleView=this.dataGrid;this._searchableElement=this.profileDataGridTree;break;}
  488. var isFlame=this._viewType.get()===WebInspector.CPUProfileView._TypeFlame;this.focusButton.setVisible(!isFlame);this.excludeButton.setVisible(!isFlame);this.resetButton.setVisible(!isFlame);this._visibleView.show(this._searchableView.element);},_focusClicked:function(event)
  489. {if(!this.dataGrid.selectedNode)
  490. return;this.resetButton.setVisible(true);this.profileDataGridTree.focus(this.dataGrid.selectedNode);this.refresh();this.refreshVisibleData();},_excludeClicked:function(event)
  491. {var selectedNode=this.dataGrid.selectedNode;if(!selectedNode)
  492. return;selectedNode.deselect();this.resetButton.setVisible(true);this.profileDataGridTree.exclude(selectedNode);this.refresh();this.refreshVisibleData();},_resetClicked:function(event)
  493. {this.resetButton.setVisible(false);this.profileDataGridTree.restore();this._linkifier.reset();this.refresh();this.refreshVisibleData();},_dataGridNodeSelected:function(node)
  494. {this.focusButton.setEnabled(true);this.excludeButton.setEnabled(true);},_dataGridNodeDeselected:function(node)
  495. {this.focusButton.setEnabled(false);this.excludeButton.setEnabled(false);},_sortProfile:function()
  496. {var sortAscending=this.dataGrid.isSortOrderAscending();var sortColumnIdentifier=this.dataGrid.sortColumnIdentifier();var sortProperty={"self":"selfTime","total":"totalTime","function":"functionName"}[sortColumnIdentifier];this.profileDataGridTree.sort(WebInspector.ProfileDataGridTree.propertyComparator(sortProperty,sortAscending));this.refresh();},__proto__:WebInspector.VBox.prototype}
  497. WebInspector.CPUProfileType=function()
  498. {WebInspector.ProfileType.call(this,WebInspector.CPUProfileType.TypeId,WebInspector.UIString("Collect JavaScript CPU Profile"));this._recording=false;this._nextAnonymousConsoleProfileNumber=1;this._anonymousConsoleProfileIdToTitle={};WebInspector.CPUProfileType.instance=this;WebInspector.targetManager.addModelListener(WebInspector.CPUProfilerModel,WebInspector.CPUProfilerModel.EventTypes.ConsoleProfileStarted,this._consoleProfileStarted,this);WebInspector.targetManager.addModelListener(WebInspector.CPUProfilerModel,WebInspector.CPUProfilerModel.EventTypes.ConsoleProfileFinished,this._consoleProfileFinished,this);}
  499. WebInspector.CPUProfileType.TypeId="CPU";WebInspector.CPUProfileType.prototype={fileExtension:function()
  500. {return".cpuprofile";},get buttonTooltip()
  501. {return this._recording?WebInspector.UIString("Stop CPU profiling."):WebInspector.UIString("Start CPU profiling.");},buttonClicked:function()
  502. {if(this._recording){this.stopRecordingProfile();return false;}else{this.startRecordingProfile();return true;}},get treeItemTitle()
  503. {return WebInspector.UIString("CPU PROFILES");},get description()
  504. {return WebInspector.UIString("CPU profiles show where the execution time is spent in your page's JavaScript functions.");},_consoleProfileStarted:function(event)
  505. {var protocolId=(event.data.protocolId);var scriptLocation=(event.data.scriptLocation);var resolvedTitle=(event.data.title);if(!resolvedTitle){resolvedTitle=WebInspector.UIString("Profile %s",this._nextAnonymousConsoleProfileNumber++);this._anonymousConsoleProfileIdToTitle[protocolId]=resolvedTitle;}
  506. this._addMessageToConsole(WebInspector.ConsoleMessage.MessageType.Profile,scriptLocation,WebInspector.UIString("Profile '%s' started.",resolvedTitle));},_consoleProfileFinished:function(event)
  507. {var protocolId=(event.data.protocolId);var scriptLocation=(event.data.scriptLocation);var cpuProfile=(event.data.cpuProfile);var resolvedTitle=(event.data.title);if(typeof resolvedTitle==="undefined"){resolvedTitle=this._anonymousConsoleProfileIdToTitle[protocolId];delete this._anonymousConsoleProfileIdToTitle[protocolId];}
  508. var profile=new WebInspector.CPUProfileHeader(scriptLocation.target(),this,resolvedTitle);profile.setProtocolProfile(cpuProfile);this.addProfile(profile);this._addMessageToConsole(WebInspector.ConsoleMessage.MessageType.ProfileEnd,scriptLocation,WebInspector.UIString("Profile '%s' finished.",resolvedTitle));},_addMessageToConsole:function(type,scriptLocation,messageText)
  509. {var script=scriptLocation.script();var target=scriptLocation.target();var message=new WebInspector.ConsoleMessage(target,WebInspector.ConsoleMessage.MessageSource.ConsoleAPI,WebInspector.ConsoleMessage.MessageLevel.Debug,messageText,type,undefined,undefined,undefined,undefined,undefined,[{functionName:"",scriptId:scriptLocation.scriptId,url:script?script.contentURL():"",lineNumber:scriptLocation.lineNumber,columnNumber:scriptLocation.columnNumber||0}]);target.consoleModel.addMessage(message);},startRecordingProfile:function()
  510. {var target=WebInspector.context.flavor(WebInspector.Target);if(this._profileBeingRecorded||!target)
  511. return;var profile=new WebInspector.CPUProfileHeader(target,this);this.setProfileBeingRecorded(profile);this.addProfile(profile);profile.updateStatus(WebInspector.UIString("Recording\u2026"));this._recording=true;target.cpuProfilerModel.startRecording();},stopRecordingProfile:function()
  512. {this._recording=false;if(!this._profileBeingRecorded||!this._profileBeingRecorded.target())
  513. return;function didStopProfiling(profile)
  514. {if(!this._profileBeingRecorded)
  515. return;this._profileBeingRecorded.setProtocolProfile(profile);this._profileBeingRecorded.updateStatus("");var recordedProfile=this._profileBeingRecorded;this.setProfileBeingRecorded(null);this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProfileComplete,recordedProfile);}
  516. this._profileBeingRecorded.target().cpuProfilerModel.stopRecording().then(didStopProfiling.bind(this));},createProfileLoadedFromFile:function(title)
  517. {return new WebInspector.CPUProfileHeader(null,this,title);},profileBeingRecordedRemoved:function()
  518. {this.stopRecordingProfile();},__proto__:WebInspector.ProfileType.prototype}
  519. WebInspector.CPUProfileHeader=function(target,type,title)
  520. {WebInspector.ProfileHeader.call(this,target,type,title||WebInspector.UIString("Profile %d",type.nextProfileUid()));this._tempFile=null;}
  521. WebInspector.CPUProfileHeader.prototype={onTransferStarted:function()
  522. {this._jsonifiedProfile="";this.updateStatus(WebInspector.UIString("Loading\u2026 %s",Number.bytesToString(this._jsonifiedProfile.length)),true);},onChunkTransferred:function(reader)
  523. {this.updateStatus(WebInspector.UIString("Loading\u2026 %d\%",Number.bytesToString(this._jsonifiedProfile.length)));},onTransferFinished:function()
  524. {this.updateStatus(WebInspector.UIString("Parsing\u2026"),true);this._profile=JSON.parse(this._jsonifiedProfile);this._jsonifiedProfile=null;this.updateStatus(WebInspector.UIString("Loaded"),false);if(this._profileType.profileBeingRecorded()===this)
  525. this._profileType.setProfileBeingRecorded(null);},onError:function(reader,e)
  526. {var subtitle;switch(e.target.error.code){case e.target.error.NOT_FOUND_ERR:subtitle=WebInspector.UIString("'%s' not found.",reader.fileName());break;case e.target.error.NOT_READABLE_ERR:subtitle=WebInspector.UIString("'%s' is not readable",reader.fileName());break;case e.target.error.ABORT_ERR:return;default:subtitle=WebInspector.UIString("'%s' error %d",reader.fileName(),e.target.error.code);}
  527. this.updateStatus(subtitle);},write:function(text)
  528. {this._jsonifiedProfile+=text;},close:function(){},dispose:function()
  529. {this.removeTempFile();},createSidebarTreeElement:function(panel)
  530. {return new WebInspector.ProfileSidebarTreeElement(panel,this,"profile-sidebar-tree-item");},createView:function()
  531. {return new WebInspector.CPUProfileView(this);},canSaveToFile:function()
  532. {return!this.fromFile()&&this._protocolProfile;},saveToFile:function()
  533. {var fileOutputStream=new WebInspector.FileOutputStream();function onOpenForSave(accepted)
  534. {if(!accepted)
  535. return;function didRead(data)
  536. {if(data)
  537. fileOutputStream.write(data,fileOutputStream.close.bind(fileOutputStream));else
  538. fileOutputStream.close();}
  539. if(this._failedToCreateTempFile){WebInspector.console.error("Failed to open temp file with heap snapshot");fileOutputStream.close();}else if(this._tempFile){this._tempFile.read(didRead);}else{this._onTempFileReady=onOpenForSave.bind(this,accepted);}}
  540. this._fileName=this._fileName||"CPU-"+new Date().toISO8601Compact()+this._profileType.fileExtension();fileOutputStream.open(this._fileName,onOpenForSave.bind(this));},loadFromFile:function(file)
  541. {this.updateStatus(WebInspector.UIString("Loading\u2026"),true);var fileReader=new WebInspector.ChunkedFileReader(file,10000000,this);fileReader.start(this);},protocolProfile:function()
  542. {return this._protocolProfile;},setProtocolProfile:function(cpuProfile)
  543. {this._protocolProfile=cpuProfile;this._saveProfileDataToTempFile(cpuProfile);if(this.canSaveToFile())
  544. this.dispatchEventToListeners(WebInspector.ProfileHeader.Events.ProfileReceived);},_saveProfileDataToTempFile:function(data)
  545. {var serializedData=JSON.stringify(data);function didCreateTempFile(tempFile)
  546. {this._writeToTempFile(tempFile,serializedData);}
  547. WebInspector.TempFile.create("cpu-profiler",String(this.uid)).then(didCreateTempFile.bind(this));},_writeToTempFile:function(tempFile,serializedData)
  548. {this._tempFile=tempFile;if(!tempFile){this._failedToCreateTempFile=true;this._notifyTempFileReady();return;}
  549. function didWriteToTempFile(fileSize)
  550. {if(!fileSize)
  551. this._failedToCreateTempFile=true;tempFile.finishWriting();this._notifyTempFileReady();}
  552. tempFile.write([serializedData],didWriteToTempFile.bind(this));},_notifyTempFileReady:function()
  553. {if(this._onTempFileReady){this._onTempFileReady();this._onTempFileReady=null;}},__proto__:WebInspector.ProfileHeader.prototype};WebInspector.HeapSnapshotProgressEvent={Update:"ProgressUpdate",BrokenSnapshot:"BrokenSnapshot"};WebInspector.HeapSnapshotCommon={}
  554. WebInspector.HeapSnapshotCommon.baseSystemDistance=100000000;WebInspector.HeapSnapshotCommon.AllocationNodeCallers=function(nodesWithSingleCaller,branchingCallers)
  555. {this.nodesWithSingleCaller=nodesWithSingleCaller;this.branchingCallers=branchingCallers;}
  556. WebInspector.HeapSnapshotCommon.SerializedAllocationNode=function(nodeId,functionName,scriptName,scriptId,line,column,count,size,liveCount,liveSize,hasChildren)
  557. {this.id=nodeId;this.name=functionName;this.scriptName=scriptName;this.scriptId=scriptId;this.line=line;this.column=column;this.count=count;this.size=size;this.liveCount=liveCount;this.liveSize=liveSize;this.hasChildren=hasChildren;}
  558. WebInspector.HeapSnapshotCommon.AllocationStackFrame=function(functionName,scriptName,scriptId,line,column)
  559. {this.functionName=functionName;this.scriptName=scriptName;this.scriptId=scriptId;this.line=line;this.column=column;}
  560. WebInspector.HeapSnapshotCommon.Node=function(id,name,distance,nodeIndex,retainedSize,selfSize,type)
  561. {this.id=id;this.name=name;this.distance=distance;this.nodeIndex=nodeIndex;this.retainedSize=retainedSize;this.selfSize=selfSize;this.type=type;this.canBeQueried=false;this.detachedDOMTreeNode=false;}
  562. WebInspector.HeapSnapshotCommon.Edge=function(name,node,type,edgeIndex)
  563. {this.name=name;this.node=node;this.type=type;this.edgeIndex=edgeIndex;};WebInspector.HeapSnapshotCommon.Aggregate=function()
  564. {this.count;this.distance;this.self;this.maxRet;this.type;this.name;this.idxs;}
  565. WebInspector.HeapSnapshotCommon.AggregateForDiff=function(){this.indexes=[];this.ids=[];this.selfSizes=[];}
  566. WebInspector.HeapSnapshotCommon.Diff=function()
  567. {this.addedCount=0;this.removedCount=0;this.addedSize=0;this.removedSize=0;this.deletedIndexes=[];this.addedIndexes=[];}
  568. WebInspector.HeapSnapshotCommon.DiffForClass=function()
  569. {this.addedCount;this.removedCount;this.addedSize;this.removedSize;this.deletedIndexes;this.addedIndexes;this.countDelta;this.sizeDelta;}
  570. WebInspector.HeapSnapshotCommon.ComparatorConfig=function()
  571. {this.fieldName1;this.ascending1;this.fieldName2;this.ascending2;}
  572. WebInspector.HeapSnapshotCommon.WorkerCommand=function()
  573. {this.callId;this.disposition;this.objectId;this.newObjectId;this.methodName;this.methodArguments;this.source;}
  574. WebInspector.HeapSnapshotCommon.ItemsRange=function(startPosition,endPosition,totalLength,items)
  575. {this.startPosition=startPosition;this.endPosition=endPosition;this.totalLength=totalLength;this.items=items;}
  576. WebInspector.HeapSnapshotCommon.StaticData=function(nodeCount,rootNodeIndex,totalSize,maxJSObjectId)
  577. {this.nodeCount=nodeCount;this.rootNodeIndex=rootNodeIndex;this.totalSize=totalSize;this.maxJSObjectId=maxJSObjectId;}
  578. WebInspector.HeapSnapshotCommon.Statistics=function()
  579. {this.total;this.v8heap;this.native;this.code;this.jsArrays;this.strings;this.system;}
  580. WebInspector.HeapSnapshotCommon.NodeFilter=function(minNodeId,maxNodeId)
  581. {this.minNodeId=minNodeId;this.maxNodeId=maxNodeId;this.allocationNodeId;}
  582. WebInspector.HeapSnapshotCommon.NodeFilter.prototype={equals:function(o)
  583. {return this.minNodeId===o.minNodeId&&this.maxNodeId===o.maxNodeId&&this.allocationNodeId===o.allocationNodeId;}}
  584. WebInspector.HeapSnapshotCommon.SearchConfig=function(query,caseSensitive,isRegex,shouldJump,jumpBackward)
  585. {this.query=query;this.caseSensitive=caseSensitive;this.isRegex=isRegex;this.shouldJump=shouldJump;this.jumpBackward=jumpBackward;};WebInspector.HeapSnapshotWorkerProxy=function(eventHandler)
  586. {this._eventHandler=eventHandler;this._nextObjectId=1;this._nextCallId=1;this._callbacks=[];this._previousCallbacks=[];this._worker=new WorkerRuntime.Worker("heap_snapshot_worker");this._worker.onmessage=this._messageReceived.bind(this);}
  587. WebInspector.HeapSnapshotWorkerProxy.prototype={createLoader:function(profileUid,snapshotReceivedCallback)
  588. {var objectId=this._nextObjectId++;var proxy=new WebInspector.HeapSnapshotLoaderProxy(this,objectId,profileUid,snapshotReceivedCallback);this._postMessage({callId:this._nextCallId++,disposition:"create",objectId:objectId,methodName:"WebInspector.HeapSnapshotLoader"});return proxy;},dispose:function()
  589. {this._worker.terminate();if(this._interval)
  590. clearInterval(this._interval);},disposeObject:function(objectId)
  591. {this._postMessage({callId:this._nextCallId++,disposition:"dispose",objectId:objectId});},evaluateForTest:function(script,callback)
  592. {var callId=this._nextCallId++;this._callbacks[callId]=callback;this._postMessage({callId:callId,disposition:"evaluateForTest",source:script});},callFactoryMethod:function(callback,objectId,methodName,proxyConstructor)
  593. {var callId=this._nextCallId++;var methodArguments=Array.prototype.slice.call(arguments,4);var newObjectId=this._nextObjectId++;function wrapCallback(remoteResult)
  594. {callback(remoteResult?new proxyConstructor(this,newObjectId):null);}
  595. if(callback){this._callbacks[callId]=wrapCallback.bind(this);this._postMessage({callId:callId,disposition:"factory",objectId:objectId,methodName:methodName,methodArguments:methodArguments,newObjectId:newObjectId});return null;}else{this._postMessage({callId:callId,disposition:"factory",objectId:objectId,methodName:methodName,methodArguments:methodArguments,newObjectId:newObjectId});return new proxyConstructor(this,newObjectId);}},callMethod:function(callback,objectId,methodName)
  596. {var callId=this._nextCallId++;var methodArguments=Array.prototype.slice.call(arguments,3);if(callback)
  597. this._callbacks[callId]=callback;this._postMessage({callId:callId,disposition:"method",objectId:objectId,methodName:methodName,methodArguments:methodArguments});},startCheckingForLongRunningCalls:function()
  598. {if(this._interval)
  599. return;this._checkLongRunningCalls();this._interval=setInterval(this._checkLongRunningCalls.bind(this),300);},_checkLongRunningCalls:function()
  600. {for(var callId in this._previousCallbacks)
  601. if(!(callId in this._callbacks))
  602. delete this._previousCallbacks[callId];var hasLongRunningCalls=false;for(callId in this._previousCallbacks){hasLongRunningCalls=true;break;}
  603. this.dispatchEventToListeners("wait",hasLongRunningCalls);for(callId in this._callbacks)
  604. this._previousCallbacks[callId]=true;},_messageReceived:function(event)
  605. {var data=event.data;if(data.eventName){if(this._eventHandler)
  606. this._eventHandler(data.eventName,data.data);return;}
  607. if(data.error){if(data.errorMethodName)
  608. WebInspector.console.error(WebInspector.UIString("An error occurred when a call to method '%s' was requested",data.errorMethodName));WebInspector.console.error(data["errorCallStack"]);delete this._callbacks[data.callId];return;}
  609. if(!this._callbacks[data.callId])
  610. return;var callback=this._callbacks[data.callId];delete this._callbacks[data.callId];callback(data.result);},_postMessage:function(message)
  611. {this._worker.postMessage(message);},__proto__:WebInspector.Object.prototype}
  612. WebInspector.HeapSnapshotProxyObject=function(worker,objectId)
  613. {this._worker=worker;this._objectId=objectId;}
  614. WebInspector.HeapSnapshotProxyObject.prototype={_callWorker:function(workerMethodName,args)
  615. {args.splice(1,0,this._objectId);return this._worker[workerMethodName].apply(this._worker,args);},dispose:function()
  616. {this._worker.disposeObject(this._objectId);},disposeWorker:function()
  617. {this._worker.dispose();},callFactoryMethod:function(callback,methodName,proxyConstructor,var_args)
  618. {return this._callWorker("callFactoryMethod",Array.prototype.slice.call(arguments,0));},callMethod:function(callback,methodName,var_args)
  619. {return this._callWorker("callMethod",Array.prototype.slice.call(arguments,0));},_callMethodPromise:function(methodName,var_args)
  620. {function action(args,fulfill)
  621. {this._callWorker("callMethod",[fulfill].concat(args));}
  622. return new Promise(action.bind(this,Array.prototype.slice.call(arguments)));}};WebInspector.HeapSnapshotLoaderProxy=function(worker,objectId,profileUid,snapshotReceivedCallback)
  623. {WebInspector.HeapSnapshotProxyObject.call(this,worker,objectId);this._profileUid=profileUid;this._snapshotReceivedCallback=snapshotReceivedCallback;}
  624. WebInspector.HeapSnapshotLoaderProxy.prototype={write:function(chunk,callback)
  625. {this.callMethod(callback,"write",chunk);},close:function(callback)
  626. {function buildSnapshot()
  627. {if(callback)
  628. callback();var showHiddenData=WebInspector.settings.showAdvancedHeapSnapshotProperties.get();this.callFactoryMethod(updateStaticData.bind(this),"buildSnapshot",WebInspector.HeapSnapshotProxy,showHiddenData);}
  629. function updateStaticData(snapshotProxy)
  630. {this.dispose();snapshotProxy.setProfileUid(this._profileUid);snapshotProxy.updateStaticData(this._snapshotReceivedCallback.bind(this));}
  631. this.callMethod(buildSnapshot.bind(this),"close");},__proto__:WebInspector.HeapSnapshotProxyObject.prototype}
  632. WebInspector.HeapSnapshotProxy=function(worker,objectId)
  633. {WebInspector.HeapSnapshotProxyObject.call(this,worker,objectId);this._staticData=null;}
  634. WebInspector.HeapSnapshotProxy.prototype={search:function(searchConfig,filter,callback)
  635. {this.callMethod(callback,"search",searchConfig,filter);},aggregatesWithFilter:function(filter,callback)
  636. {this.callMethod(callback,"aggregatesWithFilter",filter);},aggregatesForDiff:function(callback)
  637. {this.callMethod(callback,"aggregatesForDiff");},calculateSnapshotDiff:function(baseSnapshotId,baseSnapshotAggregates,callback)
  638. {this.callMethod(callback,"calculateSnapshotDiff",baseSnapshotId,baseSnapshotAggregates);},nodeClassName:function(snapshotObjectId,callback)
  639. {this.callMethod(callback,"nodeClassName",snapshotObjectId);},createEdgesProvider:function(nodeIndex)
  640. {return this.callFactoryMethod(null,"createEdgesProvider",WebInspector.HeapSnapshotProviderProxy,nodeIndex);},createRetainingEdgesProvider:function(nodeIndex)
  641. {return this.callFactoryMethod(null,"createRetainingEdgesProvider",WebInspector.HeapSnapshotProviderProxy,nodeIndex);},createAddedNodesProvider:function(baseSnapshotId,className)
  642. {return this.callFactoryMethod(null,"createAddedNodesProvider",WebInspector.HeapSnapshotProviderProxy,baseSnapshotId,className);},createDeletedNodesProvider:function(nodeIndexes)
  643. {return this.callFactoryMethod(null,"createDeletedNodesProvider",WebInspector.HeapSnapshotProviderProxy,nodeIndexes);},createNodesProvider:function(filter)
  644. {return this.callFactoryMethod(null,"createNodesProvider",WebInspector.HeapSnapshotProviderProxy,filter);},createNodesProviderForClass:function(className,nodeFilter)
  645. {return this.callFactoryMethod(null,"createNodesProviderForClass",WebInspector.HeapSnapshotProviderProxy,className,nodeFilter);},allocationTracesTops:function(callback)
  646. {this.callMethod(callback,"allocationTracesTops");},allocationNodeCallers:function(nodeId,callback)
  647. {this.callMethod(callback,"allocationNodeCallers",nodeId);},allocationStack:function(nodeIndex,callback)
  648. {this.callMethod(callback,"allocationStack",nodeIndex);},dispose:function()
  649. {throw new Error("Should never be called");},get nodeCount()
  650. {return this._staticData.nodeCount;},get rootNodeIndex()
  651. {return this._staticData.rootNodeIndex;},updateStaticData:function(callback)
  652. {function dataReceived(staticData)
  653. {this._staticData=staticData;callback(this);}
  654. this.callMethod(dataReceived.bind(this),"updateStaticData");},getStatistics:function()
  655. {return this._callMethodPromise("getStatistics");},get totalSize()
  656. {return this._staticData.totalSize;},get uid()
  657. {return this._profileUid;},setProfileUid:function(profileUid)
  658. {this._profileUid=profileUid;},maxJSObjectId:function()
  659. {return this._staticData.maxJSObjectId;},__proto__:WebInspector.HeapSnapshotProxyObject.prototype}
  660. WebInspector.HeapSnapshotProviderProxy=function(worker,objectId)
  661. {WebInspector.HeapSnapshotProxyObject.call(this,worker,objectId);}
  662. WebInspector.HeapSnapshotProviderProxy.prototype={nodePosition:function(snapshotObjectId,callback)
  663. {this.callMethod(callback,"nodePosition",snapshotObjectId);},isEmpty:function(callback)
  664. {this.callMethod(callback,"isEmpty");},serializeItemsRange:function(startPosition,endPosition,callback)
  665. {this.callMethod(callback,"serializeItemsRange",startPosition,endPosition);},sortAndRewind:function(comparator,callback)
  666. {this.callMethod(callback,"sortAndRewind",comparator);},__proto__:WebInspector.HeapSnapshotProxyObject.prototype};WebInspector.HeapSnapshotSortableDataGrid=function(dataDisplayDelegate,columns)
  667. {WebInspector.DataGrid.call(this,columns);this._dataDisplayDelegate=dataDisplayDelegate;this._recursiveSortingDepth=0;this._highlightedNode=null;this._populatedAndSorted=false;this._nameFilter=null;this._nodeFilter=new WebInspector.HeapSnapshotCommon.NodeFilter();this.addEventListener(WebInspector.HeapSnapshotSortableDataGrid.Events.SortingComplete,this._sortingComplete,this);this.addEventListener(WebInspector.DataGrid.Events.SortingChanged,this.sortingChanged,this);}
  668. WebInspector.HeapSnapshotSortableDataGrid.Events={ContentShown:"ContentShown",SortingComplete:"SortingComplete"}
  669. WebInspector.HeapSnapshotSortableDataGrid.prototype={nodeFilter:function()
  670. {return this._nodeFilter;},setNameFilter:function(nameFilter)
  671. {this._nameFilter=nameFilter;},defaultPopulateCount:function()
  672. {return 100;},_disposeAllNodes:function()
  673. {var children=this.topLevelNodes();for(var i=0,l=children.length;i<l;++i)
  674. children[i].dispose();},wasShown:function()
  675. {if(this._nameFilter){this._nameFilter.addEventListener(WebInspector.StatusBarInput.Event.TextChanged,this._onNameFilterChanged,this);this.updateVisibleNodes(true);}
  676. if(this._populatedAndSorted)
  677. this.dispatchEventToListeners(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown,this);},_sortingComplete:function()
  678. {this.removeEventListener(WebInspector.HeapSnapshotSortableDataGrid.Events.SortingComplete,this._sortingComplete,this);this._populatedAndSorted=true;this.dispatchEventToListeners(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown,this);},willHide:function()
  679. {if(this._nameFilter)
  680. this._nameFilter.removeEventListener(WebInspector.StatusBarInput.Event.TextChanged,this._onNameFilterChanged,this);this._clearCurrentHighlight();},populateContextMenu:function(contextMenu,event)
  681. {var td=event.target.enclosingNodeOrSelfWithNodeName("td");if(!td)
  682. return;var node=td.heapSnapshotNode;function revealInSummaryView()
  683. {this._dataDisplayDelegate.showObject(node.snapshotNodeId,"Summary");}
  684. if(node instanceof WebInspector.HeapSnapshotRetainingObjectNode)
  685. contextMenu.appendItem(WebInspector.UIString.capitalize("Reveal in Summary ^view"),revealInSummaryView.bind(this));},resetSortingCache:function()
  686. {delete this._lastSortColumnIdentifier;delete this._lastSortAscending;},topLevelNodes:function()
  687. {return this.rootNode().children;},revealObjectByHeapSnapshotId:function(heapSnapshotObjectId,callback)
  688. {},highlightNode:function(node)
  689. {this._clearCurrentHighlight();this._highlightedNode=node;WebInspector.runCSSAnimationOnce(this._highlightedNode.element(),"highlighted-row");},nodeWasDetached:function(node)
  690. {if(this._highlightedNode===node)
  691. this._clearCurrentHighlight();},_clearCurrentHighlight:function()
  692. {if(!this._highlightedNode)
  693. return
  694. this._highlightedNode.element().classList.remove("highlighted-row");this._highlightedNode=null;},resetNameFilter:function()
  695. {this._nameFilter.setValue("");},_onNameFilterChanged:function()
  696. {this.updateVisibleNodes(true);},sortingChanged:function()
  697. {var sortAscending=this.isSortOrderAscending();var sortColumnIdentifier=this.sortColumnIdentifier();if(this._lastSortColumnIdentifier===sortColumnIdentifier&&this._lastSortAscending===sortAscending)
  698. return;this._lastSortColumnIdentifier=sortColumnIdentifier;this._lastSortAscending=sortAscending;var sortFields=this._sortFields(sortColumnIdentifier,sortAscending);function SortByTwoFields(nodeA,nodeB)
  699. {var field1=nodeA[sortFields[0]];var field2=nodeB[sortFields[0]];var result=field1<field2?-1:(field1>field2?1:0);if(!sortFields[1])
  700. result=-result;if(result!==0)
  701. return result;field1=nodeA[sortFields[2]];field2=nodeB[sortFields[2]];result=field1<field2?-1:(field1>field2?1:0);if(!sortFields[3])
  702. result=-result;return result;}
  703. this._performSorting(SortByTwoFields);},_performSorting:function(sortFunction)
  704. {this.recursiveSortingEnter();var children=this.allChildren(this.rootNode());this.rootNode().removeChildren();children.sort(sortFunction);for(var i=0,l=children.length;i<l;++i){var child=children[i];this.appendChildAfterSorting(child);if(child.expanded)
  705. child.sort();}
  706. this.recursiveSortingLeave();},appendChildAfterSorting:function(child)
  707. {var revealed=child.revealed;this.rootNode().appendChild(child);child.revealed=revealed;},recursiveSortingEnter:function()
  708. {++this._recursiveSortingDepth;},recursiveSortingLeave:function()
  709. {if(!this._recursiveSortingDepth)
  710. return;if(--this._recursiveSortingDepth)
  711. return;this.updateVisibleNodes(true);this.dispatchEventToListeners(WebInspector.HeapSnapshotSortableDataGrid.Events.SortingComplete);},updateVisibleNodes:function(force)
  712. {},allChildren:function(parent)
  713. {return parent.children;},insertChild:function(parent,node,index)
  714. {parent.insertChild(node,index);},removeChildByIndex:function(parent,index)
  715. {parent.removeChild(parent.children[index]);},removeAllChildren:function(parent)
  716. {parent.removeChildren();},__proto__:WebInspector.DataGrid.prototype}
  717. WebInspector.HeapSnapshotViewportDataGrid=function(dataDisplayDelegate,columns)
  718. {WebInspector.HeapSnapshotSortableDataGrid.call(this,dataDisplayDelegate,columns);this.scrollContainer.addEventListener("scroll",this._onScroll.bind(this),true);this._topPaddingHeight=0;this._bottomPaddingHeight=0;}
  719. WebInspector.HeapSnapshotViewportDataGrid.prototype={topLevelNodes:function()
  720. {return this.allChildren(this.rootNode());},appendChildAfterSorting:function(child)
  721. {},updateVisibleNodes:function(force)
  722. {var guardZoneHeight=40;var scrollHeight=this.scrollContainer.scrollHeight;var scrollTop=this.scrollContainer.scrollTop;var scrollBottom=scrollHeight-scrollTop-this.scrollContainer.offsetHeight;scrollTop=Math.max(0,scrollTop-guardZoneHeight);scrollBottom=Math.max(0,scrollBottom-guardZoneHeight);var viewPortHeight=scrollHeight-scrollTop-scrollBottom;if(!force&&scrollTop>=this._topPaddingHeight&&scrollBottom>=this._bottomPaddingHeight)
  723. return;var hysteresisHeight=500;scrollTop-=hysteresisHeight;viewPortHeight+=2*hysteresisHeight;var selectedNode=this.selectedNode;this.rootNode().removeChildren();this._topPaddingHeight=0;this._bottomPaddingHeight=0;this._addVisibleNodes(this.rootNode(),scrollTop,scrollTop+viewPortHeight);this.setVerticalPadding(this._topPaddingHeight,this._bottomPaddingHeight);if(selectedNode){if(selectedNode.parent)
  724. selectedNode.select(true);else
  725. this.selectedNode=selectedNode;}},_addVisibleNodes:function(parentNode,topBound,bottomBound)
  726. {if(!parentNode.expanded)
  727. return 0;var children=this.allChildren(parentNode);var topPadding=0;var nameFilterValue=this._nameFilter?this._nameFilter.value().toLowerCase():"";for(var i=0;i<children.length;++i){var child=children[i];if(nameFilterValue&&child.filteredOut&&child.filteredOut(nameFilterValue))
  728. continue;var newTop=topPadding+this._nodeHeight(child);if(newTop>topBound)
  729. break;topPadding=newTop;}
  730. var position=topPadding;for(;i<children.length&&position<bottomBound;++i){var child=children[i];if(nameFilterValue&&child.filteredOut&&child.filteredOut(nameFilterValue))
  731. continue;var hasChildren=child.hasChildren;child.removeChildren();child.hasChildren=hasChildren;child.revealed=true;parentNode.appendChild(child);position+=child.nodeSelfHeight();position+=this._addVisibleNodes(child,topBound-position,bottomBound-position);}
  732. var bottomPadding=0;for(;i<children.length;++i){var child=children[i];if(nameFilterValue&&child.filteredOut&&child.filteredOut(nameFilterValue))
  733. continue;bottomPadding+=this._nodeHeight(child);}
  734. this._topPaddingHeight+=topPadding;this._bottomPaddingHeight+=bottomPadding;return position+bottomPadding;},_nodeHeight:function(node)
  735. {if(!node.revealed)
  736. return 0;var result=node.nodeSelfHeight();if(!node.expanded)
  737. return result;var children=this.allChildren(node);for(var i=0;i<children.length;i++)
  738. result+=this._nodeHeight(children[i]);return result;},revealTreeNode:function(pathToReveal)
  739. {var height=this._calculateOffset(pathToReveal);var node=(pathToReveal.peekLast());var scrollTop=this.scrollContainer.scrollTop;var scrollBottom=scrollTop+this.scrollContainer.offsetHeight;if(height>=scrollTop&&height<scrollBottom)
  740. return Promise.resolve(node);var scrollGap=40;this.scrollContainer.scrollTop=Math.max(0,height-scrollGap);return new Promise(this._scrollTo.bind(this,node));},_scrollTo:function(node,fulfill)
  741. {console.assert(!this._scrollToResolveCallback);this._scrollToResolveCallback=fulfill.bind(null,node);},_calculateOffset:function(pathToReveal)
  742. {var parentNode=this.rootNode();var height=0;for(var i=0;i<pathToReveal.length;++i){var node=pathToReveal[i];var children=this.allChildren(parentNode);for(var j=0;j<children.length;++j){var child=children[j];if(node===child){height+=node.nodeSelfHeight();break;}
  743. height+=this._nodeHeight(child);}
  744. parentNode=node;}
  745. return height-pathToReveal.peekLast().nodeSelfHeight();},allChildren:function(parent)
  746. {return parent._allChildren||(parent._allChildren=[]);},appendNode:function(parent,node)
  747. {this.allChildren(parent).push(node);},insertChild:function(parent,node,index)
  748. {this.allChildren(parent).splice(index,0,node);},removeChildByIndex:function(parent,index)
  749. {this.allChildren(parent).splice(index,1);},removeAllChildren:function(parent)
  750. {parent._allChildren=[];},removeTopLevelNodes:function()
  751. {this._disposeAllNodes();this.rootNode().removeChildren();this.rootNode()._allChildren=[];},_isScrolledIntoView:function(element)
  752. {var viewportTop=this.scrollContainer.scrollTop;var viewportBottom=viewportTop+this.scrollContainer.clientHeight;var elemTop=element.offsetTop;var elemBottom=elemTop+element.offsetHeight;return elemBottom<=viewportBottom&&elemTop>=viewportTop;},onResize:function()
  753. {WebInspector.HeapSnapshotSortableDataGrid.prototype.onResize.call(this);this.updateVisibleNodes(false);},_onScroll:function(event)
  754. {this.updateVisibleNodes(false);if(this._scrollToResolveCallback){this._scrollToResolveCallback();this._scrollToResolveCallback=null;}},__proto__:WebInspector.HeapSnapshotSortableDataGrid.prototype}
  755. WebInspector.HeapSnapshotContainmentDataGrid=function(dataDisplayDelegate,columns)
  756. {columns=columns||[{id:"object",title:WebInspector.UIString("Object"),disclosure:true,sortable:true},{id:"distance",title:WebInspector.UIString("Distance"),width:"80px",sortable:true},{id:"shallowSize",title:WebInspector.UIString("Shallow Size"),width:"120px",sortable:true},{id:"retainedSize",title:WebInspector.UIString("Retained Size"),width:"120px",sortable:true,sort:WebInspector.DataGrid.Order.Descending}];WebInspector.HeapSnapshotSortableDataGrid.call(this,dataDisplayDelegate,columns);}
  757. WebInspector.HeapSnapshotContainmentDataGrid.prototype={setDataSource:function(snapshot,nodeIndex)
  758. {this.snapshot=snapshot;var node={nodeIndex:nodeIndex||snapshot.rootNodeIndex};var fakeEdge={node:node};this.setRootNode(this._createRootNode(snapshot,fakeEdge));this.rootNode().sort();},_createRootNode:function(snapshot,fakeEdge)
  759. {return new WebInspector.HeapSnapshotObjectNode(this,snapshot,fakeEdge,null);},sortingChanged:function()
  760. {var rootNode=this.rootNode();if(rootNode.hasChildren)
  761. rootNode.sort();},__proto__:WebInspector.HeapSnapshotSortableDataGrid.prototype}
  762. WebInspector.HeapSnapshotRetainmentDataGrid=function(dataDisplayDelegate)
  763. {var columns=[{id:"object",title:WebInspector.UIString("Object"),disclosure:true,sortable:true},{id:"distance",title:WebInspector.UIString("Distance"),width:"80px",sortable:true,sort:WebInspector.DataGrid.Order.Ascending},{id:"shallowSize",title:WebInspector.UIString("Shallow Size"),width:"120px",sortable:true},{id:"retainedSize",title:WebInspector.UIString("Retained Size"),width:"120px",sortable:true}];WebInspector.HeapSnapshotContainmentDataGrid.call(this,dataDisplayDelegate,columns);}
  764. WebInspector.HeapSnapshotRetainmentDataGrid.Events={ExpandRetainersComplete:"ExpandRetainersComplete"}
  765. WebInspector.HeapSnapshotRetainmentDataGrid.prototype={_createRootNode:function(snapshot,fakeEdge)
  766. {return new WebInspector.HeapSnapshotRetainingObjectNode(this,snapshot,fakeEdge,null);},_sortFields:function(sortColumn,sortAscending)
  767. {return{object:["_name",sortAscending,"_count",false],count:["_count",sortAscending,"_name",true],shallowSize:["_shallowSize",sortAscending,"_name",true],retainedSize:["_retainedSize",sortAscending,"_name",true],distance:["_distance",sortAscending,"_name",true]}[sortColumn];},reset:function()
  768. {this.rootNode().removeChildren();this.resetSortingCache();},setDataSource:function(snapshot,nodeIndex)
  769. {WebInspector.HeapSnapshotContainmentDataGrid.prototype.setDataSource.call(this,snapshot,nodeIndex);this.rootNode().expand();},__proto__:WebInspector.HeapSnapshotContainmentDataGrid.prototype}
  770. WebInspector.HeapSnapshotConstructorsDataGrid=function(dataDisplayDelegate)
  771. {var columns=[{id:"object",title:WebInspector.UIString("Constructor"),disclosure:true,sortable:true},{id:"distance",title:WebInspector.UIString("Distance"),width:"90px",sortable:true},{id:"count",title:WebInspector.UIString("Objects Count"),width:"90px",sortable:true},{id:"shallowSize",title:WebInspector.UIString("Shallow Size"),width:"120px",sortable:true},{id:"retainedSize",title:WebInspector.UIString("Retained Size"),width:"120px",sort:WebInspector.DataGrid.Order.Descending,sortable:true}];WebInspector.HeapSnapshotViewportDataGrid.call(this,dataDisplayDelegate,columns);this._profileIndex=-1;this._objectIdToSelect=null;}
  772. WebInspector.HeapSnapshotConstructorsDataGrid.prototype={_sortFields:function(sortColumn,sortAscending)
  773. {return{object:["_name",sortAscending,"_count",false],distance:["_distance",sortAscending,"_retainedSize",true],count:["_count",sortAscending,"_name",true],shallowSize:["_shallowSize",sortAscending,"_name",true],retainedSize:["_retainedSize",sortAscending,"_name",true]}[sortColumn];},revealObjectByHeapSnapshotId:function(id,callback)
  774. {if(!this.snapshot){this._objectIdToSelect=id;return;}
  775. function didPopulateNode(parentNode,node)
  776. {if(node)
  777. this.revealTreeNode([parentNode,node]).then(callback);else
  778. callback(node);}
  779. function didGetClassName(className)
  780. {if(!className){callback(null);return;}
  781. var constructorNodes=this.topLevelNodes();for(var i=0;i<constructorNodes.length;i++){var parent=constructorNodes[i];if(parent._name===className){parent.populateNodeBySnapshotObjectId(parseInt(id,10),didPopulateNode.bind(this));return;}}}
  782. this.snapshot.nodeClassName(parseInt(id,10),didGetClassName.bind(this));},clear:function()
  783. {this._nextRequestedFilter=null;this._lastFilter=null;this.removeTopLevelNodes();},setDataSource:function(snapshot)
  784. {this.snapshot=snapshot;if(this._profileIndex===-1)
  785. this._populateChildren();if(this._objectIdToSelect){this.revealObjectByHeapSnapshotId(this._objectIdToSelect,function(){});this._objectIdToSelect=null;}},setSelectionRange:function(minNodeId,maxNodeId)
  786. {this._nodeFilter=new WebInspector.HeapSnapshotCommon.NodeFilter(minNodeId,maxNodeId);this._populateChildren(this._nodeFilter);},setAllocationNodeId:function(allocationNodeId)
  787. {this._nodeFilter=new WebInspector.HeapSnapshotCommon.NodeFilter();this._nodeFilter.allocationNodeId=allocationNodeId;this._populateChildren(this._nodeFilter);},_aggregatesReceived:function(nodeFilter,aggregates)
  788. {this._filterInProgress=null;if(this._nextRequestedFilter){this.snapshot.aggregatesWithFilter(this._nextRequestedFilter,this._aggregatesReceived.bind(this,this._nextRequestedFilter));this._filterInProgress=this._nextRequestedFilter;this._nextRequestedFilter=null;}
  789. this.removeTopLevelNodes();this.resetSortingCache();for(var constructor in aggregates)
  790. this.appendNode(this.rootNode(),new WebInspector.HeapSnapshotConstructorNode(this,constructor,aggregates[constructor],nodeFilter));this.sortingChanged();this._lastFilter=nodeFilter;},_populateChildren:function(nodeFilter)
  791. {nodeFilter=nodeFilter||new WebInspector.HeapSnapshotCommon.NodeFilter();if(this._filterInProgress){this._nextRequestedFilter=this._filterInProgress.equals(nodeFilter)?null:nodeFilter;return;}
  792. if(this._lastFilter&&this._lastFilter.equals(nodeFilter))
  793. return;this._filterInProgress=nodeFilter;this.snapshot.aggregatesWithFilter(nodeFilter,this._aggregatesReceived.bind(this,nodeFilter));},filterSelectIndexChanged:function(profiles,profileIndex)
  794. {this._profileIndex=profileIndex;this._nodeFilter=undefined;if(profileIndex!==-1){var minNodeId=profileIndex>0?profiles[profileIndex-1].maxJSObjectId:0;var maxNodeId=profiles[profileIndex].maxJSObjectId;this._nodeFilter=new WebInspector.HeapSnapshotCommon.NodeFilter(minNodeId,maxNodeId);}
  795. this._populateChildren(this._nodeFilter);},__proto__:WebInspector.HeapSnapshotViewportDataGrid.prototype}
  796. WebInspector.HeapSnapshotDiffDataGrid=function(dataDisplayDelegate)
  797. {var columns=[{id:"object",title:WebInspector.UIString("Constructor"),disclosure:true,sortable:true},{id:"addedCount",title:WebInspector.UIString("# New"),width:"72px",sortable:true},{id:"removedCount",title:WebInspector.UIString("# Deleted"),width:"72px",sortable:true},{id:"countDelta",title:WebInspector.UIString("# Delta"),width:"64px",sortable:true},{id:"addedSize",title:WebInspector.UIString("Alloc. Size"),width:"72px",sortable:true,sort:WebInspector.DataGrid.Order.Descending},{id:"removedSize",title:WebInspector.UIString("Freed Size"),width:"72px",sortable:true},{id:"sizeDelta",title:WebInspector.UIString("Size Delta"),width:"72px",sortable:true}];WebInspector.HeapSnapshotViewportDataGrid.call(this,dataDisplayDelegate,columns);}
  798. WebInspector.HeapSnapshotDiffDataGrid.prototype={defaultPopulateCount:function()
  799. {return 50;},_sortFields:function(sortColumn,sortAscending)
  800. {return{object:["_name",sortAscending,"_count",false],addedCount:["_addedCount",sortAscending,"_name",true],removedCount:["_removedCount",sortAscending,"_name",true],countDelta:["_countDelta",sortAscending,"_name",true],addedSize:["_addedSize",sortAscending,"_name",true],removedSize:["_removedSize",sortAscending,"_name",true],sizeDelta:["_sizeDelta",sortAscending,"_name",true]}[sortColumn];},setDataSource:function(snapshot)
  801. {this.snapshot=snapshot;},setBaseDataSource:function(baseSnapshot)
  802. {this.baseSnapshot=baseSnapshot;this.removeTopLevelNodes();this.resetSortingCache();if(this.baseSnapshot===this.snapshot){this.dispatchEventToListeners(WebInspector.HeapSnapshotSortableDataGrid.Events.SortingComplete);return;}
  803. this._populateChildren();},_populateChildren:function()
  804. {function aggregatesForDiffReceived(aggregatesForDiff)
  805. {this.snapshot.calculateSnapshotDiff(this.baseSnapshot.uid,aggregatesForDiff,didCalculateSnapshotDiff.bind(this));function didCalculateSnapshotDiff(diffByClassName)
  806. {for(var className in diffByClassName){var diff=diffByClassName[className];this.appendNode(this.rootNode(),new WebInspector.HeapSnapshotDiffNode(this,className,diff));}
  807. this.sortingChanged();}}
  808. this.baseSnapshot.aggregatesForDiff(aggregatesForDiffReceived.bind(this));},__proto__:WebInspector.HeapSnapshotViewportDataGrid.prototype}
  809. WebInspector.AllocationDataGrid=function(target,dataDisplayDelegate)
  810. {var columns=[{id:"liveCount",title:WebInspector.UIString("Live Count"),width:"72px",sortable:true},{id:"count",title:WebInspector.UIString("Count"),width:"72px",sortable:true},{id:"liveSize",title:WebInspector.UIString("Live Size"),width:"72px",sortable:true},{id:"size",title:WebInspector.UIString("Size"),width:"72px",sortable:true,sort:WebInspector.DataGrid.Order.Descending},{id:"name",title:WebInspector.UIString("Function"),disclosure:true,sortable:true},];WebInspector.HeapSnapshotViewportDataGrid.call(this,dataDisplayDelegate,columns);this._target=target;this._linkifier=new WebInspector.Linkifier();}
  811. WebInspector.AllocationDataGrid.prototype={target:function()
  812. {return this._target;},dispose:function()
  813. {this._linkifier.reset();},setDataSource:function(snapshot)
  814. {this.snapshot=snapshot;this.snapshot.allocationTracesTops(didReceiveAllocationTracesTops.bind(this));function didReceiveAllocationTracesTops(tops)
  815. {this._topNodes=tops;this._populateChildren();}},_populateChildren:function()
  816. {this.removeTopLevelNodes();var root=this.rootNode();var tops=this._topNodes;for(var i=0;i<tops.length;i++)
  817. this.appendNode(root,new WebInspector.AllocationGridNode(this,tops[i]));this.updateVisibleNodes(true);},sortingChanged:function()
  818. {this._topNodes.sort(this._createComparator());this.rootNode().removeChildren();this._populateChildren();},_createComparator:function()
  819. {var fieldName=this.sortColumnIdentifier();var compareResult=(this.sortOrder()===WebInspector.DataGrid.Order.Ascending)?+1:-1;function compare(a,b)
  820. {if(a[fieldName]>b[fieldName])
  821. return compareResult;if(a[fieldName]<b[fieldName])
  822. return-compareResult;return 0;}
  823. return compare;},__proto__:WebInspector.HeapSnapshotViewportDataGrid.prototype};WebInspector.HeapSnapshotGridNode=function(tree,hasChildren)
  824. {WebInspector.DataGridNode.call(this,null,hasChildren);this._dataGrid=tree;this._instanceCount=0;this._savedChildren=null;this._retrievedChildrenRanges=[];this._providerObject=null;}
  825. WebInspector.HeapSnapshotGridNode.Events={PopulateComplete:"PopulateComplete"}
  826. WebInspector.HeapSnapshotGridNode.createComparator=function(fieldNames)
  827. {return({fieldName1:fieldNames[0],ascending1:fieldNames[1],fieldName2:fieldNames[2],ascending2:fieldNames[3]});}
  828. WebInspector.HeapSnapshotGridNode.ChildrenProvider=function(){}
  829. WebInspector.HeapSnapshotGridNode.ChildrenProvider.prototype={dispose:function(){},nodePosition:function(snapshotObjectId,callback){},isEmpty:function(callback){},serializeItemsRange:function(startPosition,endPosition,callback){},sortAndRewind:function(comparator,callback){}}
  830. WebInspector.HeapSnapshotGridNode.prototype={heapSnapshotDataGrid:function()
  831. {return this._dataGrid;},createProvider:function()
  832. {throw new Error("Not implemented.");},retainersDataSource:function()
  833. {return null;},_provider:function()
  834. {if(!this._providerObject)
  835. this._providerObject=this.createProvider();return this._providerObject;},createCell:function(columnIdentifier)
  836. {var cell=WebInspector.DataGridNode.prototype.createCell.call(this,columnIdentifier);if(this._searchMatched)
  837. cell.classList.add("highlight");return cell;},collapse:function()
  838. {WebInspector.DataGridNode.prototype.collapse.call(this);this._dataGrid.updateVisibleNodes(true);},expand:function()
  839. {WebInspector.DataGridNode.prototype.expand.call(this);this._dataGrid.updateVisibleNodes(true);},dispose:function()
  840. {if(this._providerObject)
  841. this._providerObject.dispose();for(var node=this.children[0];node;node=node.traverseNextNode(true,this,true))
  842. if(node.dispose)
  843. node.dispose();},_reachableFromWindow:false,queryObjectContent:function(callback)
  844. {},wasDetached:function()
  845. {this._dataGrid.nodeWasDetached(this);},_toPercentString:function(num)
  846. {return num.toFixed(0)+"\u2009%";},_toUIDistance:function(distance)
  847. {var baseSystemDistance=WebInspector.HeapSnapshotCommon.baseSystemDistance;return distance>=0&&distance<baseSystemDistance?WebInspector.UIString("%d",distance):WebInspector.UIString("\u2212");},allChildren:function()
  848. {return this._dataGrid.allChildren(this);},removeChildByIndex:function(index)
  849. {this._dataGrid.removeChildByIndex(this,index);},childForPosition:function(nodePosition)
  850. {var indexOfFirstChildInRange=0;for(var i=0;i<this._retrievedChildrenRanges.length;i++){var range=this._retrievedChildrenRanges[i];if(range.from<=nodePosition&&nodePosition<range.to){var childIndex=indexOfFirstChildInRange+nodePosition-range.from;return this.allChildren()[childIndex];}
  851. indexOfFirstChildInRange+=range.to-range.from+1;}
  852. return null;},_createValueCell:function(columnIdentifier)
  853. {var cell=createElement("td");cell.className="numeric-column";if(this.dataGrid.snapshot.totalSize!==0){var div=createElement("div");var valueSpan=createElement("span");valueSpan.textContent=this.data[columnIdentifier];div.appendChild(valueSpan);var percentColumn=columnIdentifier+"-percent";if(percentColumn in this.data){var percentSpan=createElement("span");percentSpan.className="percent-column";percentSpan.textContent=this.data[percentColumn];div.appendChild(percentSpan);div.classList.add("profile-multiple-values");}
  854. cell.appendChild(div);}
  855. return cell;},populate:function(event)
  856. {if(this._populated)
  857. return;this._populated=true;function sorted()
  858. {this._populateChildren();}
  859. this._provider().sortAndRewind(this.comparator(),sorted.bind(this));},expandWithoutPopulate:function(callback)
  860. {this._populated=true;this.expand();this._provider().sortAndRewind(this.comparator(),callback);},_populateChildren:function(fromPosition,toPosition,afterPopulate)
  861. {fromPosition=fromPosition||0;toPosition=toPosition||fromPosition+this._dataGrid.defaultPopulateCount();var firstNotSerializedPosition=fromPosition;function serializeNextChunk()
  862. {if(firstNotSerializedPosition>=toPosition)
  863. return;var end=Math.min(firstNotSerializedPosition+this._dataGrid.defaultPopulateCount(),toPosition);this._provider().serializeItemsRange(firstNotSerializedPosition,end,childrenRetrieved.bind(this));firstNotSerializedPosition=end;}
  864. function insertRetrievedChild(item,insertionIndex)
  865. {if(this._savedChildren){var hash=this._childHashForEntity(item);if(hash in this._savedChildren){this._dataGrid.insertChild(this,this._savedChildren[hash],insertionIndex);return;}}
  866. this._dataGrid.insertChild(this,this._createChildNode(item),insertionIndex);}
  867. function insertShowMoreButton(from,to,insertionIndex)
  868. {var button=new WebInspector.ShowMoreDataGridNode(this._populateChildren.bind(this),from,to,this._dataGrid.defaultPopulateCount());this._dataGrid.insertChild(this,button,insertionIndex);}
  869. function childrenRetrieved(itemsRange)
  870. {var itemIndex=0;var itemPosition=itemsRange.startPosition;var items=itemsRange.items;var insertionIndex=0;if(!this._retrievedChildrenRanges.length){if(itemsRange.startPosition>0){this._retrievedChildrenRanges.push({from:0,to:0});insertShowMoreButton.call(this,0,itemsRange.startPosition,insertionIndex++);}
  871. this._retrievedChildrenRanges.push({from:itemsRange.startPosition,to:itemsRange.endPosition});for(var i=0,l=items.length;i<l;++i)
  872. insertRetrievedChild.call(this,items[i],insertionIndex++);if(itemsRange.endPosition<itemsRange.totalLength)
  873. insertShowMoreButton.call(this,itemsRange.endPosition,itemsRange.totalLength,insertionIndex++);}else{var rangeIndex=0;var found=false;var range;while(rangeIndex<this._retrievedChildrenRanges.length){range=this._retrievedChildrenRanges[rangeIndex];if(range.to>=itemPosition){found=true;break;}
  874. insertionIndex+=range.to-range.from;if(range.to<itemsRange.totalLength)
  875. insertionIndex+=1;++rangeIndex;}
  876. if(!found||itemsRange.startPosition<range.from){this.allChildren()[insertionIndex-1].setEndPosition(itemsRange.startPosition);insertShowMoreButton.call(this,itemsRange.startPosition,found?range.from:itemsRange.totalLength,insertionIndex);range={from:itemsRange.startPosition,to:itemsRange.startPosition};if(!found)
  877. rangeIndex=this._retrievedChildrenRanges.length;this._retrievedChildrenRanges.splice(rangeIndex,0,range);}else{insertionIndex+=itemPosition-range.from;}
  878. while(range.to<itemsRange.endPosition){var skipCount=range.to-itemPosition;insertionIndex+=skipCount;itemIndex+=skipCount;itemPosition=range.to;var nextRange=this._retrievedChildrenRanges[rangeIndex+1];var newEndOfRange=nextRange?nextRange.from:itemsRange.totalLength;if(newEndOfRange>itemsRange.endPosition)
  879. newEndOfRange=itemsRange.endPosition;while(itemPosition<newEndOfRange){insertRetrievedChild.call(this,items[itemIndex++],insertionIndex++);++itemPosition;}
  880. if(nextRange&&newEndOfRange===nextRange.from){range.to=nextRange.to;this.removeChildByIndex(insertionIndex);this._retrievedChildrenRanges.splice(rangeIndex+1,1);}else{range.to=newEndOfRange;if(newEndOfRange===itemsRange.totalLength)
  881. this.removeChildByIndex(insertionIndex);else
  882. this.allChildren()[insertionIndex].setStartPosition(itemsRange.endPosition);}}}
  883. this._instanceCount+=items.length;if(firstNotSerializedPosition<toPosition){serializeNextChunk.call(this);return;}
  884. if(this.expanded)
  885. this._dataGrid.updateVisibleNodes(true);if(afterPopulate)
  886. afterPopulate();this.dispatchEventToListeners(WebInspector.HeapSnapshotGridNode.Events.PopulateComplete);}
  887. serializeNextChunk.call(this);},_saveChildren:function()
  888. {this._savedChildren=null;var children=this.allChildren();for(var i=0,l=children.length;i<l;++i){var child=children[i];if(!child.expanded)
  889. continue;if(!this._savedChildren)
  890. this._savedChildren={};this._savedChildren[this._childHashForNode(child)]=child;}},sort:function()
  891. {this._dataGrid.recursiveSortingEnter();function afterSort()
  892. {this._saveChildren();this._dataGrid.removeAllChildren(this);this._retrievedChildrenRanges=[];function afterPopulate()
  893. {var children=this.allChildren();for(var i=0,l=children.length;i<l;++i){var child=children[i];if(child.expanded)
  894. child.sort();}
  895. this._dataGrid.recursiveSortingLeave();}
  896. var instanceCount=this._instanceCount;this._instanceCount=0;this._populateChildren(0,instanceCount,afterPopulate.bind(this));}
  897. this._provider().sortAndRewind(this.comparator(),afterSort.bind(this));},__proto__:WebInspector.DataGridNode.prototype}
  898. WebInspector.HeapSnapshotGenericObjectNode=function(dataGrid,node)
  899. {WebInspector.HeapSnapshotGridNode.call(this,dataGrid,false);if(!node)
  900. return;this._name=node.name;this._type=node.type;this._distance=node.distance;this._shallowSize=node.selfSize;this._retainedSize=node.retainedSize;this.snapshotNodeId=node.id;this.snapshotNodeIndex=node.nodeIndex;if(this._type==="string")
  901. this._reachableFromWindow=true;else if(this._type==="object"&&this._name.startsWith("Window")){this._name=this.shortenWindowURL(this._name,false);this._reachableFromWindow=true;}else if(node.canBeQueried)
  902. this._reachableFromWindow=true;if(node.detachedDOMTreeNode)
  903. this.detachedDOMTreeNode=true;var snapshot=dataGrid.snapshot;var shallowSizePercent=this._shallowSize/snapshot.totalSize*100.0;var retainedSizePercent=this._retainedSize/snapshot.totalSize*100.0;this.data={"distance":this._toUIDistance(this._distance),"shallowSize":Number.withThousandsSeparator(this._shallowSize),"retainedSize":Number.withThousandsSeparator(this._retainedSize),"shallowSize-percent":this._toPercentString(shallowSizePercent),"retainedSize-percent":this._toPercentString(retainedSizePercent)};};WebInspector.HeapSnapshotGenericObjectNode.prototype={retainersDataSource:function()
  904. {return{snapshot:this._dataGrid.snapshot,snapshotNodeIndex:this.snapshotNodeIndex};},createCell:function(columnIdentifier)
  905. {var cell=columnIdentifier!=="object"?this._createValueCell(columnIdentifier):this._createObjectCell();if(this._searchMatched)
  906. cell.classList.add("highlight");return cell;},_createObjectCell:function()
  907. {var value=this._name;var valueStyle="object";switch(this._type){case"concatenated string":case"string":value="\""+value+"\"";valueStyle="string";break;case"regexp":value="/"+value+"/";valueStyle="string";break;case"closure":value="function"+(value?" ":"")+value+"()";valueStyle="function";break;case"number":valueStyle="number";break;case"hidden":valueStyle="null";break;case"array":if(!value)
  908. value="[]";else
  909. value+="[]";break;};if(this._reachableFromWindow)
  910. valueStyle+=" highlight";if(value==="Object")
  911. value="";if(this.detachedDOMTreeNode)
  912. valueStyle+=" detached-dom-tree-node";return this._createObjectCellWithValue(valueStyle,value);},_createObjectCellWithValue:function(valueStyle,value)
  913. {var cell=createElement("td");cell.className="object-column";var div=createElement("div");div.className="source-code event-properties";div.style.overflow="visible";this._prefixObjectCell(div);var valueSpan=createElement("span");valueSpan.className="value console-formatted-"+valueStyle;valueSpan.textContent=value;div.appendChild(valueSpan);var idSpan=createElement("span");idSpan.className="console-formatted-id";idSpan.textContent=" @"+this.snapshotNodeId;div.appendChild(idSpan);cell.appendChild(div);cell.classList.add("disclosure");if(this.depth)
  914. cell.style.setProperty("padding-left",(this.depth*this.dataGrid.indentWidth)+"px");cell.heapSnapshotNode=this;return cell;},_prefixObjectCell:function(div)
  915. {},queryObjectContent:function(target,callback,objectGroupName)
  916. {function formatResult(error,object)
  917. {if(!error&&object.type)
  918. callback(target.runtimeModel.createRemoteObject(object));else
  919. callback(target.runtimeModel.createRemoteObjectFromPrimitiveValue(WebInspector.UIString("Preview is not available")));}
  920. if(this._type==="string")
  921. callback(target.runtimeModel.createRemoteObjectFromPrimitiveValue(this._name));else
  922. target.heapProfilerAgent().getObjectByHeapObjectId(String(this.snapshotNodeId),objectGroupName,formatResult);},updateHasChildren:function()
  923. {function isEmptyCallback(isEmpty)
  924. {this.hasChildren=!isEmpty;}
  925. this._provider().isEmpty(isEmptyCallback.bind(this));},shortenWindowURL:function(fullName,hasObjectId)
  926. {var startPos=fullName.indexOf("/");var endPos=hasObjectId?fullName.indexOf("@"):fullName.length;if(startPos!==-1&&endPos!==-1){var fullURL=fullName.substring(startPos+1,endPos).trimLeft();var url=fullURL.trimURL();if(url.length>40)
  927. url=url.trimMiddle(40);return fullName.substr(0,startPos+2)+url+fullName.substr(endPos);}else
  928. return fullName;},__proto__:WebInspector.HeapSnapshotGridNode.prototype}
  929. WebInspector.HeapSnapshotObjectNode=function(dataGrid,snapshot,edge,parentObjectNode)
  930. {WebInspector.HeapSnapshotGenericObjectNode.call(this,dataGrid,edge.node);this._referenceName=edge.name;this._referenceType=edge.type;this._edgeIndex=edge.edgeIndex;this._snapshot=snapshot;this._parentObjectNode=parentObjectNode;this._cycledWithAncestorGridNode=this._findAncestorWithSameSnapshotNodeId();if(!this._cycledWithAncestorGridNode)
  931. this.updateHasChildren();var data=this.data;data["count"]="";data["addedCount"]="";data["removedCount"]="";data["countDelta"]="";data["addedSize"]="";data["removedSize"]="";data["sizeDelta"]="";}
  932. WebInspector.HeapSnapshotObjectNode.prototype={retainersDataSource:function()
  933. {return{snapshot:this._snapshot,snapshotNodeIndex:this.snapshotNodeIndex};},createProvider:function()
  934. {return this._snapshot.createEdgesProvider(this.snapshotNodeIndex);},_findAncestorWithSameSnapshotNodeId:function()
  935. {var ancestor=this._parentObjectNode;while(ancestor){if(ancestor.snapshotNodeId===this.snapshotNodeId)
  936. return ancestor;ancestor=ancestor._parentObjectNode;}
  937. return null;},_createChildNode:function(item)
  938. {return new WebInspector.HeapSnapshotObjectNode(this._dataGrid,this._snapshot,item,this);},_childHashForEntity:function(edge)
  939. {return edge.edgeIndex;},_childHashForNode:function(childNode)
  940. {return childNode._edgeIndex;},comparator:function()
  941. {var sortAscending=this._dataGrid.isSortOrderAscending();var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();var sortFields={object:["!edgeName",sortAscending,"retainedSize",false],count:["!edgeName",true,"retainedSize",false],shallowSize:["selfSize",sortAscending,"!edgeName",true],retainedSize:["retainedSize",sortAscending,"!edgeName",true],distance:["distance",sortAscending,"_name",true]}[sortColumnIdentifier]||["!edgeName",true,"retainedSize",false];return WebInspector.HeapSnapshotGridNode.createComparator(sortFields);},_prefixObjectCell:function(div)
  942. {var name=this._referenceName;if(name==="")name="(empty)";var nameClass="name";switch(this._referenceType){case"context":nameClass="console-formatted-number";break;case"internal":case"hidden":case"weak":nameClass="console-formatted-null";break;case"element":name="["+name+"]";break;}
  943. if(this._cycledWithAncestorGridNode)
  944. div.className+=" cycled-ancessor-node";var nameSpan=createElement("span");nameSpan.className=nameClass;nameSpan.textContent=name;div.appendChild(nameSpan);var separatorSpan=createElement("span");separatorSpan.className="grayed";separatorSpan.textContent=this._edgeNodeSeparator();div.appendChild(separatorSpan);},_edgeNodeSeparator:function()
  945. {return" :: ";},__proto__:WebInspector.HeapSnapshotGenericObjectNode.prototype}
  946. WebInspector.HeapSnapshotRetainingObjectNode=function(dataGrid,snapshot,edge,parentRetainingObjectNode)
  947. {WebInspector.HeapSnapshotObjectNode.call(this,dataGrid,snapshot,edge,parentRetainingObjectNode);}
  948. WebInspector.HeapSnapshotRetainingObjectNode.prototype={createProvider:function()
  949. {return this._snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex);},_createChildNode:function(item)
  950. {return new WebInspector.HeapSnapshotRetainingObjectNode(this._dataGrid,this._snapshot,item,this);},_edgeNodeSeparator:function()
  951. {return" in ";},expand:function()
  952. {this._expandRetainersChain(20);},_expandRetainersChain:function(maxExpandLevels)
  953. {function populateComplete()
  954. {this.removeEventListener(WebInspector.HeapSnapshotGridNode.Events.PopulateComplete,populateComplete,this);this._expandRetainersChain(maxExpandLevels);}
  955. if(!this._populated){this.addEventListener(WebInspector.HeapSnapshotGridNode.Events.PopulateComplete,populateComplete,this);this.populate();return;}
  956. WebInspector.HeapSnapshotGenericObjectNode.prototype.expand.call(this);if(--maxExpandLevels>0&&this.children.length>0){var retainer=this.children[0];if(retainer._distance>1){retainer._expandRetainersChain(maxExpandLevels);return;}}
  957. this._dataGrid.dispatchEventToListeners(WebInspector.HeapSnapshotRetainmentDataGrid.Events.ExpandRetainersComplete);},__proto__:WebInspector.HeapSnapshotObjectNode.prototype}
  958. WebInspector.HeapSnapshotInstanceNode=function(dataGrid,snapshot,node,isDeletedNode)
  959. {WebInspector.HeapSnapshotGenericObjectNode.call(this,dataGrid,node);this._baseSnapshotOrSnapshot=snapshot;this._isDeletedNode=isDeletedNode;this.updateHasChildren();var data=this.data;data["count"]="";data["countDelta"]="";data["sizeDelta"]="";if(this._isDeletedNode){data["addedCount"]="";data["addedSize"]="";data["removedCount"]="\u2022";data["removedSize"]=Number.withThousandsSeparator(this._shallowSize);}else{data["addedCount"]="\u2022";data["addedSize"]=Number.withThousandsSeparator(this._shallowSize);data["removedCount"]="";data["removedSize"]="";}};WebInspector.HeapSnapshotInstanceNode.prototype={retainersDataSource:function()
  960. {return{snapshot:this._baseSnapshotOrSnapshot,snapshotNodeIndex:this.snapshotNodeIndex};},createProvider:function()
  961. {return this._baseSnapshotOrSnapshot.createEdgesProvider(this.snapshotNodeIndex);},_createChildNode:function(item)
  962. {return new WebInspector.HeapSnapshotObjectNode(this._dataGrid,this._baseSnapshotOrSnapshot,item,null);},_childHashForEntity:function(edge)
  963. {return edge.edgeIndex;},_childHashForNode:function(childNode)
  964. {return childNode._edgeIndex;},comparator:function()
  965. {var sortAscending=this._dataGrid.isSortOrderAscending();var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();var sortFields={object:["!edgeName",sortAscending,"retainedSize",false],distance:["distance",sortAscending,"retainedSize",false],count:["!edgeName",true,"retainedSize",false],addedSize:["selfSize",sortAscending,"!edgeName",true],removedSize:["selfSize",sortAscending,"!edgeName",true],shallowSize:["selfSize",sortAscending,"!edgeName",true],retainedSize:["retainedSize",sortAscending,"!edgeName",true]}[sortColumnIdentifier]||["!edgeName",true,"retainedSize",false];return WebInspector.HeapSnapshotGridNode.createComparator(sortFields);},__proto__:WebInspector.HeapSnapshotGenericObjectNode.prototype}
  966. WebInspector.HeapSnapshotConstructorNode=function(dataGrid,className,aggregate,nodeFilter)
  967. {WebInspector.HeapSnapshotGridNode.call(this,dataGrid,aggregate.count>0);this._name=className;this._nodeFilter=nodeFilter;this._distance=aggregate.distance;this._count=aggregate.count;this._shallowSize=aggregate.self;this._retainedSize=aggregate.maxRet;var snapshot=dataGrid.snapshot;var countPercent=this._count/snapshot.nodeCount*100.0;var retainedSizePercent=this._retainedSize/snapshot.totalSize*100.0;var shallowSizePercent=this._shallowSize/snapshot.totalSize*100.0;this.data={"object":className,"count":Number.withThousandsSeparator(this._count),"distance":this._toUIDistance(this._distance),"shallowSize":Number.withThousandsSeparator(this._shallowSize),"retainedSize":Number.withThousandsSeparator(this._retainedSize),"count-percent":this._toPercentString(countPercent),"shallowSize-percent":this._toPercentString(shallowSizePercent),"retainedSize-percent":this._toPercentString(retainedSizePercent)};}
  968. WebInspector.HeapSnapshotConstructorNode.prototype={createProvider:function()
  969. {return this._dataGrid.snapshot.createNodesProviderForClass(this._name,this._nodeFilter)},populateNodeBySnapshotObjectId:function(snapshotObjectId,callback)
  970. {function didExpand()
  971. {this._provider().nodePosition(snapshotObjectId,didGetNodePosition.bind(this));}
  972. function didGetNodePosition(nodePosition)
  973. {if(nodePosition===-1){this.collapse();callback(null,null);}else{this._populateChildren(nodePosition,null,didPopulateChildren.bind(this,nodePosition));}}
  974. function didPopulateChildren(nodePosition)
  975. {callback(this,(this.childForPosition(nodePosition)));}
  976. this._dataGrid.resetNameFilter();this.expandWithoutPopulate(didExpand.bind(this));},filteredOut:function(filterValue)
  977. {return this._name.toLowerCase().indexOf(filterValue)===-1;},createCell:function(columnIdentifier)
  978. {var cell=columnIdentifier!=="object"?this._createValueCell(columnIdentifier):WebInspector.HeapSnapshotGridNode.prototype.createCell.call(this,columnIdentifier);if(this._searchMatched)
  979. cell.classList.add("highlight");return cell;},_createChildNode:function(item)
  980. {return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid,this._dataGrid.snapshot,item,false);},comparator:function()
  981. {var sortAscending=this._dataGrid.isSortOrderAscending();var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();var sortFields={object:["id",sortAscending,"retainedSize",false],distance:["distance",sortAscending,"retainedSize",false],count:["id",true,"retainedSize",false],shallowSize:["selfSize",sortAscending,"id",true],retainedSize:["retainedSize",sortAscending,"id",true]}[sortColumnIdentifier];return WebInspector.HeapSnapshotGridNode.createComparator(sortFields);},_childHashForEntity:function(node)
  982. {return node.id;},_childHashForNode:function(childNode)
  983. {return childNode.snapshotNodeId;},__proto__:WebInspector.HeapSnapshotGridNode.prototype}
  984. WebInspector.HeapSnapshotDiffNodesProvider=function(addedNodesProvider,deletedNodesProvider,addedCount,removedCount)
  985. {this._addedNodesProvider=addedNodesProvider;this._deletedNodesProvider=deletedNodesProvider;this._addedCount=addedCount;this._removedCount=removedCount;}
  986. WebInspector.HeapSnapshotDiffNodesProvider.prototype={dispose:function()
  987. {this._addedNodesProvider.dispose();this._deletedNodesProvider.dispose();},nodePosition:function(snapshotObjectId,callback)
  988. {throw new Error("Unreachable");},isEmpty:function(callback)
  989. {callback(false);},serializeItemsRange:function(beginPosition,endPosition,callback)
  990. {function didReceiveAllItems(items)
  991. {items.totalLength=this._addedCount+this._removedCount;callback(items);}
  992. function didReceiveDeletedItems(addedItems,itemsRange)
  993. {var items=itemsRange.items;if(!addedItems.items.length)
  994. addedItems.startPosition=this._addedCount+itemsRange.startPosition;for(var i=0;i<items.length;i++){items[i].isAddedNotRemoved=false;addedItems.items.push(items[i]);}
  995. addedItems.endPosition=this._addedCount+itemsRange.endPosition;didReceiveAllItems.call(this,addedItems);}
  996. function didReceiveAddedItems(itemsRange)
  997. {var items=itemsRange.items;for(var i=0;i<items.length;i++)
  998. items[i].isAddedNotRemoved=true;if(itemsRange.endPosition<endPosition)
  999. return this._deletedNodesProvider.serializeItemsRange(0,endPosition-itemsRange.endPosition,didReceiveDeletedItems.bind(this,itemsRange));itemsRange.totalLength=this._addedCount+this._removedCount;didReceiveAllItems.call(this,itemsRange);}
  1000. if(beginPosition<this._addedCount){this._addedNodesProvider.serializeItemsRange(beginPosition,endPosition,didReceiveAddedItems.bind(this));}else{var emptyRange=new WebInspector.HeapSnapshotCommon.ItemsRange(0,0,0,[]);this._deletedNodesProvider.serializeItemsRange(beginPosition-this._addedCount,endPosition-this._addedCount,didReceiveDeletedItems.bind(this,emptyRange));}},sortAndRewind:function(comparator,callback)
  1001. {function afterSort()
  1002. {this._deletedNodesProvider.sortAndRewind(comparator,callback);}
  1003. this._addedNodesProvider.sortAndRewind(comparator,afterSort.bind(this));}};WebInspector.HeapSnapshotDiffNode=function(dataGrid,className,diffForClass)
  1004. {WebInspector.HeapSnapshotGridNode.call(this,dataGrid,true);this._name=className;this._addedCount=diffForClass.addedCount;this._removedCount=diffForClass.removedCount;this._countDelta=diffForClass.countDelta;this._addedSize=diffForClass.addedSize;this._removedSize=diffForClass.removedSize;this._sizeDelta=diffForClass.sizeDelta;this._deletedIndexes=diffForClass.deletedIndexes;this.data={"object":className,"addedCount":Number.withThousandsSeparator(this._addedCount),"removedCount":Number.withThousandsSeparator(this._removedCount),"countDelta":this._signForDelta(this._countDelta)+Number.withThousandsSeparator(Math.abs(this._countDelta)),"addedSize":Number.withThousandsSeparator(this._addedSize),"removedSize":Number.withThousandsSeparator(this._removedSize),"sizeDelta":this._signForDelta(this._sizeDelta)+Number.withThousandsSeparator(Math.abs(this._sizeDelta))};}
  1005. WebInspector.HeapSnapshotDiffNode.prototype={createProvider:function()
  1006. {var tree=this._dataGrid;return new WebInspector.HeapSnapshotDiffNodesProvider(tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid,this._name),tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes),this._addedCount,this._removedCount);},createCell:function(columnIdentifier)
  1007. {var cell=WebInspector.HeapSnapshotGridNode.prototype.createCell.call(this,columnIdentifier);if(columnIdentifier!=="object")
  1008. cell.classList.add("numeric-column");return cell;},_createChildNode:function(item)
  1009. {if(item.isAddedNotRemoved)
  1010. return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid,this._dataGrid.snapshot,item,false);else
  1011. return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid,this._dataGrid.baseSnapshot,item,true);},_childHashForEntity:function(node)
  1012. {return node.id;},_childHashForNode:function(childNode)
  1013. {return childNode.snapshotNodeId;},comparator:function()
  1014. {var sortAscending=this._dataGrid.isSortOrderAscending();var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();var sortFields={object:["id",sortAscending,"selfSize",false],addedCount:["selfSize",sortAscending,"id",true],removedCount:["selfSize",sortAscending,"id",true],countDelta:["selfSize",sortAscending,"id",true],addedSize:["selfSize",sortAscending,"id",true],removedSize:["selfSize",sortAscending,"id",true],sizeDelta:["selfSize",sortAscending,"id",true]}[sortColumnIdentifier];return WebInspector.HeapSnapshotGridNode.createComparator(sortFields);},filteredOut:function(filterValue)
  1015. {return this._name.toLowerCase().indexOf(filterValue)===-1;},_signForDelta:function(delta)
  1016. {if(delta===0)
  1017. return"";if(delta>0)
  1018. return"+";else
  1019. return"\u2212";},__proto__:WebInspector.HeapSnapshotGridNode.prototype}
  1020. WebInspector.AllocationGridNode=function(dataGrid,data)
  1021. {WebInspector.HeapSnapshotGridNode.call(this,dataGrid,data.hasChildren);this._populated=false;this._allocationNode=data;this.data={"liveCount":Number.withThousandsSeparator(data.liveCount),"count":Number.withThousandsSeparator(data.count),"liveSize":Number.withThousandsSeparator(data.liveSize),"size":Number.withThousandsSeparator(data.size),"name":data.name};}
  1022. WebInspector.AllocationGridNode.prototype={populate:function()
  1023. {if(this._populated)
  1024. return;this._populated=true;this._dataGrid.snapshot.allocationNodeCallers(this._allocationNode.id,didReceiveCallers.bind(this));function didReceiveCallers(callers)
  1025. {var callersChain=callers.nodesWithSingleCaller;var parentNode=this;var dataGrid=(this._dataGrid);for(var i=0;i<callersChain.length;i++){var child=new WebInspector.AllocationGridNode(dataGrid,callersChain[i]);dataGrid.appendNode(parentNode,child);parentNode=child;parentNode._populated=true;if(this.expanded)
  1026. parentNode.expand();}
  1027. var callersBranch=callers.branchingCallers;callersBranch.sort(this._dataGrid._createComparator());for(var i=0;i<callersBranch.length;i++)
  1028. dataGrid.appendNode(parentNode,new WebInspector.AllocationGridNode(dataGrid,callersBranch[i]));dataGrid.updateVisibleNodes(true);}},expand:function()
  1029. {WebInspector.HeapSnapshotGridNode.prototype.expand.call(this);if(this.children.length===1)
  1030. this.children[0].expand();},createCell:function(columnIdentifier)
  1031. {if(columnIdentifier!=="name")
  1032. return this._createValueCell(columnIdentifier);var cell=WebInspector.HeapSnapshotGridNode.prototype.createCell.call(this,columnIdentifier);var allocationNode=this._allocationNode;var target=this._dataGrid.target();if(allocationNode.scriptId){var linkifier=this._dataGrid._linkifier;var urlElement=linkifier.linkifyScriptLocation(target,String(allocationNode.scriptId),allocationNode.scriptName,allocationNode.line-1,allocationNode.column-1,"profile-node-file");urlElement.style.maxWidth="75%";cell.insertBefore(urlElement,cell.firstChild);}
  1033. return cell;},allocationNodeId:function()
  1034. {return this._allocationNode.id;},__proto__:WebInspector.HeapSnapshotGridNode.prototype};WebInspector.HeapSnapshotView=function(dataDisplayDelegate,profile)
  1035. {WebInspector.VBox.call(this);this.element.classList.add("heap-snapshot-view");profile.profileType().addEventListener(WebInspector.HeapSnapshotProfileType.SnapshotReceived,this._onReceiveSnapshot,this);profile.profileType().addEventListener(WebInspector.ProfileType.Events.RemoveProfileHeader,this._onProfileHeaderRemoved,this);if(profile.profileType().id===WebInspector.TrackingHeapSnapshotProfileType.TypeId){this._trackingOverviewGrid=new WebInspector.HeapTrackingOverviewGrid(profile);this._trackingOverviewGrid.addEventListener(WebInspector.HeapTrackingOverviewGrid.IdsRangeChanged,this._onIdsRangeChanged.bind(this));}
  1036. this._parentDataDisplayDelegate=dataDisplayDelegate;this._searchableView=new WebInspector.SearchableView(this);this._searchableView.show(this.element);this._splitView=new WebInspector.SplitView(false,true,"heapSnapshotSplitViewState",200,200);this._splitView.show(this._searchableView.element);this._containmentView=new WebInspector.VBox();this._containmentView.setMinimumSize(50,25);this._containmentDataGrid=new WebInspector.HeapSnapshotContainmentDataGrid(this);this._containmentDataGrid.show(this._containmentView.element);this._containmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this._statisticsView=new WebInspector.HeapSnapshotStatisticsView();this._constructorsView=new WebInspector.VBox();this._constructorsView.setMinimumSize(50,25);this._constructorsDataGrid=new WebInspector.HeapSnapshotConstructorsDataGrid(this);this._constructorsDataGrid.show(this._constructorsView.element);this._constructorsDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this._diffView=new WebInspector.VBox();this._diffView.setMinimumSize(50,25);this._diffDataGrid=new WebInspector.HeapSnapshotDiffDataGrid(this);this._diffDataGrid.show(this._diffView.element);this._diffDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);if(profile._hasAllocationStacks){this._allocationView=new WebInspector.VBox();this._allocationView.setMinimumSize(50,25);this._allocationDataGrid=new WebInspector.AllocationDataGrid(profile.target(),this);this._allocationDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._onSelectAllocationNode,this);this._allocationDataGrid.show(this._allocationView.element);this._allocationStackView=new WebInspector.HeapAllocationStackView(profile.target());this._allocationStackView.setMinimumSize(50,25);this._tabbedPane=new WebInspector.TabbedPane();this._tabbedPane.setCloseableTabs(false);this._tabbedPane.headerElement().classList.add("heap-object-details-header");}
  1037. this._retainmentView=new WebInspector.VBox();this._retainmentView.setMinimumSize(50,21);this._retainmentView.element.classList.add("retaining-paths-view");var splitViewResizer;if(this._allocationStackView){this._tabbedPane=new WebInspector.TabbedPane();this._tabbedPane.setCloseableTabs(false);this._tabbedPane.headerElement().classList.add("heap-object-details-header");this._tabbedPane.appendTab("retainers",WebInspector.UIString("Retainers"),this._retainmentView);this._tabbedPane.appendTab("allocation-stack",WebInspector.UIString("Allocation stack"),this._allocationStackView);splitViewResizer=this._tabbedPane.headerElement();this._objectDetailsView=this._tabbedPane;}else{var retainmentViewHeader=createElementWithClass("div","heap-snapshot-view-resizer");var retainingPathsTitleDiv=retainmentViewHeader.createChild("div","title");var retainingPathsTitle=retainingPathsTitleDiv.createChild("span");retainingPathsTitle.textContent=WebInspector.UIString("Retainers");this._retainmentView.element.appendChild(retainmentViewHeader);splitViewResizer=retainmentViewHeader;this._objectDetailsView=this._retainmentView;}
  1038. this._splitView.hideDefaultResizer();this._splitView.installResizer(splitViewResizer);this._retainmentDataGrid=new WebInspector.HeapSnapshotRetainmentDataGrid(this);this._retainmentDataGrid.show(this._retainmentView.element);this._retainmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._inspectedObjectChanged,this);this._retainmentDataGrid.reset();this._perspectives=[];this._perspectives.push(new WebInspector.HeapSnapshotView.SummaryPerspective());if(profile.profileType()!==WebInspector.ProfileTypeRegistry.instance.trackingHeapSnapshotProfileType)
  1039. this._perspectives.push(new WebInspector.HeapSnapshotView.ComparisonPerspective());this._perspectives.push(new WebInspector.HeapSnapshotView.ContainmentPerspective());if(this._allocationView)
  1040. this._perspectives.push(new WebInspector.HeapSnapshotView.AllocationPerspective());this._perspectives.push(new WebInspector.HeapSnapshotView.StatisticsPerspective());this._perspectiveSelect=new WebInspector.StatusBarComboBox(this._onSelectedPerspectiveChanged.bind(this));for(var i=0;i<this._perspectives.length;++i)
  1041. this._perspectiveSelect.createOption(this._perspectives[i].title());this._profile=profile;this._baseSelect=new WebInspector.StatusBarComboBox(this._changeBase.bind(this));this._baseSelect.setVisible(false);this._updateBaseOptions();this._filterSelect=new WebInspector.StatusBarComboBox(this._changeFilter.bind(this));this._filterSelect.setVisible(false);this._updateFilterOptions();this._classNameFilter=new WebInspector.StatusBarInput("Class filter");this._classNameFilter.setVisible(false);this._constructorsDataGrid.setNameFilter(this._classNameFilter);this._diffDataGrid.setNameFilter(this._classNameFilter);this._selectedSizeText=new WebInspector.StatusBarText("");this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._getHoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),undefined,true);this._currentPerspectiveIndex=0;this._currentPerspective=this._perspectives[0];this._currentPerspective.activate(this);this._dataGrid=this._currentPerspective.masterGrid(this);this._refreshView();this._searchThrottler=new WebInspector.Throttler(0);}
  1042. WebInspector.HeapSnapshotView.Perspective=function(title)
  1043. {this._title=title;}
  1044. WebInspector.HeapSnapshotView.Perspective.prototype={activate:function(heapSnapshotView){},deactivate:function(heapSnapshotView)
  1045. {heapSnapshotView._baseSelect.setVisible(false);heapSnapshotView._filterSelect.setVisible(false);heapSnapshotView._classNameFilter.setVisible(false);if(heapSnapshotView._trackingOverviewGrid)
  1046. heapSnapshotView._trackingOverviewGrid.detach();if(heapSnapshotView._allocationView)
  1047. heapSnapshotView._allocationView.detach();if(heapSnapshotView._statisticsView)
  1048. heapSnapshotView._statisticsView.detach();heapSnapshotView._splitView.detach();heapSnapshotView._splitView.detachChildViews();},masterGrid:function(heapSnapshotView)
  1049. {return null;},title:function()
  1050. {return this._title;},supportsSearch:function()
  1051. {return false;}}
  1052. WebInspector.HeapSnapshotView.SummaryPerspective=function()
  1053. {WebInspector.HeapSnapshotView.Perspective.call(this,WebInspector.UIString("Summary"));}
  1054. WebInspector.HeapSnapshotView.SummaryPerspective.prototype={activate:function(heapSnapshotView)
  1055. {heapSnapshotView._splitView.setMainView(heapSnapshotView._constructorsView);heapSnapshotView._splitView.setSidebarView(heapSnapshotView._objectDetailsView);heapSnapshotView._splitView.show(heapSnapshotView._searchableView.element);heapSnapshotView._filterSelect.setVisible(true);heapSnapshotView._classNameFilter.setVisible(true);if(heapSnapshotView._trackingOverviewGrid){heapSnapshotView._trackingOverviewGrid.show(heapSnapshotView._searchableView.element,heapSnapshotView._splitView.element);heapSnapshotView._trackingOverviewGrid.update();heapSnapshotView._trackingOverviewGrid._updateGrid();}},masterGrid:function(heapSnapshotView)
  1056. {return heapSnapshotView._constructorsDataGrid;},supportsSearch:function()
  1057. {return true;},__proto__:WebInspector.HeapSnapshotView.Perspective.prototype}
  1058. WebInspector.HeapSnapshotView.ComparisonPerspective=function()
  1059. {WebInspector.HeapSnapshotView.Perspective.call(this,WebInspector.UIString("Comparison"));}
  1060. WebInspector.HeapSnapshotView.ComparisonPerspective.prototype={activate:function(heapSnapshotView)
  1061. {heapSnapshotView._splitView.setMainView(heapSnapshotView._diffView);heapSnapshotView._splitView.setSidebarView(heapSnapshotView._objectDetailsView);heapSnapshotView._splitView.show(heapSnapshotView._searchableView.element);heapSnapshotView._baseSelect.setVisible(true);heapSnapshotView._classNameFilter.setVisible(true);},masterGrid:function(heapSnapshotView)
  1062. {return heapSnapshotView._diffDataGrid;},supportsSearch:function()
  1063. {return true;},__proto__:WebInspector.HeapSnapshotView.Perspective.prototype}
  1064. WebInspector.HeapSnapshotView.ContainmentPerspective=function()
  1065. {WebInspector.HeapSnapshotView.Perspective.call(this,WebInspector.UIString("Containment"));}
  1066. WebInspector.HeapSnapshotView.ContainmentPerspective.prototype={activate:function(heapSnapshotView)
  1067. {heapSnapshotView._splitView.setMainView(heapSnapshotView._containmentView);heapSnapshotView._splitView.setSidebarView(heapSnapshotView._objectDetailsView);heapSnapshotView._splitView.show(heapSnapshotView._searchableView.element);},masterGrid:function(heapSnapshotView)
  1068. {return heapSnapshotView._containmentDataGrid;},__proto__:WebInspector.HeapSnapshotView.Perspective.prototype}
  1069. WebInspector.HeapSnapshotView.AllocationPerspective=function()
  1070. {WebInspector.HeapSnapshotView.Perspective.call(this,WebInspector.UIString("Allocation"));this._allocationSplitView=new WebInspector.SplitView(false,true,"heapSnapshotAllocationSplitViewState",200,200);this._allocationSplitView.setSidebarView(new WebInspector.VBox());var resizer=createElementWithClass("div","heap-snapshot-view-resizer");var title=resizer.createChild("div","title").createChild("span");title.textContent=WebInspector.UIString("Live objects");this._allocationSplitView.hideDefaultResizer();this._allocationSplitView.installResizer(resizer);this._allocationSplitView.sidebarView().element.appendChild(resizer);}
  1071. WebInspector.HeapSnapshotView.AllocationPerspective.prototype={activate:function(heapSnapshotView)
  1072. {this._allocationSplitView.setMainView(heapSnapshotView._allocationView);heapSnapshotView._splitView.setMainView(heapSnapshotView._constructorsView);heapSnapshotView._splitView.setSidebarView(heapSnapshotView._objectDetailsView);this._allocationSplitView.setSidebarView(heapSnapshotView._splitView);this._allocationSplitView.show(heapSnapshotView._searchableView.element);heapSnapshotView._constructorsDataGrid.clear();var selectedNode=heapSnapshotView._allocationDataGrid.selectedNode;if(selectedNode)
  1073. heapSnapshotView._constructorsDataGrid.setAllocationNodeId(selectedNode.allocationNodeId());},deactivate:function(heapSnapshotView)
  1074. {this._allocationSplitView.detach();WebInspector.HeapSnapshotView.Perspective.prototype.deactivate.call(this,heapSnapshotView);},masterGrid:function(heapSnapshotView)
  1075. {return heapSnapshotView._allocationDataGrid;},__proto__:WebInspector.HeapSnapshotView.Perspective.prototype}
  1076. WebInspector.HeapSnapshotView.StatisticsPerspective=function()
  1077. {WebInspector.HeapSnapshotView.Perspective.call(this,WebInspector.UIString("Statistics"));}
  1078. WebInspector.HeapSnapshotView.StatisticsPerspective.prototype={activate:function(heapSnapshotView)
  1079. {heapSnapshotView._statisticsView.show(heapSnapshotView._searchableView.element);},masterGrid:function(heapSnapshotView)
  1080. {return null;},__proto__:WebInspector.HeapSnapshotView.Perspective.prototype}
  1081. WebInspector.HeapSnapshotView.prototype={searchableView:function()
  1082. {return this._searchableView;},showProfile:function(profile)
  1083. {return this._parentDataDisplayDelegate.showProfile(profile);},showObject:function(snapshotObjectId,perspectiveName)
  1084. {if(snapshotObjectId<=this._profile.maxJSObjectId)
  1085. this.selectLiveObject(perspectiveName,snapshotObjectId);else
  1086. this._parentDataDisplayDelegate.showObject(snapshotObjectId,perspectiveName);},_refreshView:function()
  1087. {this._profile._loadPromise.then(profileCallback.bind(this));function profileCallback(heapSnapshotProxy)
  1088. {heapSnapshotProxy.getStatistics().then(this._gotStatistics.bind(this));var list=this._profiles();var profileIndex=list.indexOf(this._profile);this._baseSelect.setSelectedIndex(Math.max(0,profileIndex-1));this._dataGrid.setDataSource(heapSnapshotProxy);if(this._trackingOverviewGrid)
  1089. this._trackingOverviewGrid._updateGrid();}},_gotStatistics:function(statistics)
  1090. {this._statisticsView.setTotal(statistics.total);this._statisticsView.addRecord(statistics.code,WebInspector.UIString("Code"),"#f77");this._statisticsView.addRecord(statistics.strings,WebInspector.UIString("Strings"),"#5e5");this._statisticsView.addRecord(statistics.jsArrays,WebInspector.UIString("JS Arrays"),"#7af");this._statisticsView.addRecord(statistics.native,WebInspector.UIString("Typed Arrays"),"#fc5");this._statisticsView.addRecord(statistics.system,WebInspector.UIString("System Objects"),"#98f");this._statisticsView.addRecord(statistics.total,WebInspector.UIString("Total"));},_onIdsRangeChanged:function(event)
  1091. {var minId=event.data.minId;var maxId=event.data.maxId;this._selectedSizeText.setText(WebInspector.UIString("Selected size: %s",Number.bytesToString(event.data.size)));if(this._constructorsDataGrid.snapshot)
  1092. this._constructorsDataGrid.setSelectionRange(minId,maxId);},statusBarItems:function()
  1093. {var result=[this._perspectiveSelect,this._classNameFilter];if(this._profile.profileType()!==WebInspector.ProfileTypeRegistry.instance.trackingHeapSnapshotProfileType)
  1094. result.push(this._baseSelect,this._filterSelect);result.push(this._selectedSizeText);return result;},wasShown:function()
  1095. {this._profile._loadPromise.then(this._profile._wasShown.bind(this._profile));},willHide:function()
  1096. {this._currentSearchResultIndex=-1;this._popoverHelper.hidePopover();if(this.helpPopover&&this.helpPopover.isShowing())
  1097. this.helpPopover.hide();},supportsCaseSensitiveSearch:function()
  1098. {return true;},supportsRegexSearch:function()
  1099. {return false;},searchCanceled:function()
  1100. {this._currentSearchResultIndex=-1;this._searchResults=[];},_selectRevealedNode:function(callback,node)
  1101. {if(node)
  1102. node.select();callback();},performSearch:function(searchConfig,shouldJump,jumpBackwards)
  1103. {var nextQuery=new WebInspector.HeapSnapshotCommon.SearchConfig(searchConfig.query.trim(),searchConfig.caseSensitive,searchConfig.isRegex,shouldJump,jumpBackwards||false);this._searchThrottler.schedule(this._performSearch.bind(this,nextQuery));},_performSearch:function(nextQuery,callback)
  1104. {this.searchCanceled();if(!this._currentPerspective.supportsSearch()){callback();return;}
  1105. this.currentQuery=nextQuery;var query=nextQuery.query.trim();if(!query){callback();return;}
  1106. if(query.charAt(0)==="@"){var snapshotNodeId=parseInt(query.substring(1),10);if(!isNaN(snapshotNodeId))
  1107. this._dataGrid.revealObjectByHeapSnapshotId(String(snapshotNodeId),this._selectRevealedNode.bind(this,callback));else
  1108. callback();return;}
  1109. function didSearch(entryIds)
  1110. {this._searchResults=entryIds;this._searchableView.updateSearchMatchesCount(this._searchResults.length);if(this._searchResults.length)
  1111. this._currentSearchResultIndex=nextQuery.jumpBackwards?this._searchResults.length-1:0;this._jumpToSearchResult(this._currentSearchResultIndex,callback);}
  1112. this._profile._snapshotProxy.search(this.currentQuery,this._dataGrid.nodeFilter(),didSearch.bind(this));},jumpToNextSearchResult:function()
  1113. {if(!this._searchResults.length)
  1114. return;this._currentSearchResultIndex=(this._currentSearchResultIndex+1)%this._searchResults.length;this._searchThrottler.schedule(this._jumpToSearchResult.bind(this,this._currentSearchResultIndex));},jumpToPreviousSearchResult:function()
  1115. {if(!this._searchResults.length)
  1116. return;this._currentSearchResultIndex=(this._currentSearchResultIndex+this._searchResults.length-1)%this._searchResults.length;this._searchThrottler.schedule(this._jumpToSearchResult.bind(this,this._currentSearchResultIndex));},_jumpToSearchResult:function(searchResultIndex,callback)
  1117. {this._dataGrid.revealObjectByHeapSnapshotId(String(this._searchResults[searchResultIndex]),this._selectRevealedNode.bind(this,callback));this._searchableView.updateCurrentMatchIndex(searchResultIndex);},refreshVisibleData:function()
  1118. {if(!this._dataGrid)
  1119. return;var child=this._dataGrid.rootNode().children[0];while(child){child.refresh();child=child.traverseNextNode(false,null,true);}},_changeBase:function()
  1120. {if(this._baseProfile===this._profiles()[this._baseSelect.selectedIndex()])
  1121. return;this._baseProfile=this._profiles()[this._baseSelect.selectedIndex()];var dataGrid=(this._dataGrid);if(dataGrid.snapshot)
  1122. this._baseProfile._loadPromise.then(dataGrid.setBaseDataSource.bind(dataGrid));if(!this.currentQuery||!this._searchResults)
  1123. return;this.performSearch(this.currentQuery,false);},_changeFilter:function()
  1124. {var profileIndex=this._filterSelect.selectedIndex()-1;this._dataGrid.filterSelectIndexChanged(this._profiles(),profileIndex);WebInspector.notifications.dispatchEventToListeners(WebInspector.UserMetrics.UserAction,{action:WebInspector.UserMetrics.UserActionNames.HeapSnapshotFilterChanged,label:this._filterSelect.selectedOption().label});if(!this.currentQuery||!this._searchResults)
  1125. return;this.performSearch(this.currentQuery,false);},_profiles:function()
  1126. {return this._profile.profileType().getProfiles();},populateContextMenu:function(contextMenu,event)
  1127. {if(this._dataGrid)
  1128. this._dataGrid.populateContextMenu(contextMenu,event);},_selectionChanged:function(event)
  1129. {var selectedNode=event.target.selectedNode;this._setSelectedNodeForDetailsView(selectedNode);this._inspectedObjectChanged(event);},_onSelectAllocationNode:function(event)
  1130. {var selectedNode=event.target.selectedNode;this._constructorsDataGrid.setAllocationNodeId(selectedNode.allocationNodeId());this._setSelectedNodeForDetailsView(null);},_inspectedObjectChanged:function(event)
  1131. {var selectedNode=event.target.selectedNode;var target=this._profile.target();if(target&&selectedNode instanceof WebInspector.HeapSnapshotGenericObjectNode)
  1132. target.consoleAgent().addInspectedHeapObject(selectedNode.snapshotNodeId);},_setSelectedNodeForDetailsView:function(nodeItem)
  1133. {var dataSource=nodeItem&&nodeItem.retainersDataSource();if(dataSource){this._retainmentDataGrid.setDataSource(dataSource.snapshot,dataSource.snapshotNodeIndex);if(this._allocationStackView)
  1134. this._allocationStackView.setAllocatedObject(dataSource.snapshot,dataSource.snapshotNodeIndex);}else{if(this._allocationStackView)
  1135. this._allocationStackView.clear();this._retainmentDataGrid.reset();}},_changePerspectiveAndWait:function(perspectiveTitle,callback)
  1136. {var perspectiveIndex=null;for(var i=0;i<this._perspectives.length;++i){if(this._perspectives[i].title()===perspectiveTitle){perspectiveIndex=i;break;}}
  1137. if(this._currentPerspectiveIndex===perspectiveIndex||perspectiveIndex===null){setTimeout(callback,0);return;}
  1138. function dataGridContentShown(event)
  1139. {var dataGrid=event.data;dataGrid.removeEventListener(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown,dataGridContentShown,this);if(dataGrid===this._dataGrid)
  1140. callback();}
  1141. this._perspectives[perspectiveIndex].masterGrid(this).addEventListener(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown,dataGridContentShown,this);this._perspectiveSelect.setSelectedIndex(perspectiveIndex);this._changePerspective(perspectiveIndex);},_updateDataSourceAndView:function()
  1142. {var dataGrid=this._dataGrid;if(!dataGrid||dataGrid.snapshot)
  1143. return;this._profile._loadPromise.then(didLoadSnapshot.bind(this));function didLoadSnapshot(snapshotProxy)
  1144. {if(this._dataGrid!==dataGrid)
  1145. return;if(dataGrid.snapshot!==snapshotProxy)
  1146. dataGrid.setDataSource(snapshotProxy);if(dataGrid===this._diffDataGrid){if(!this._baseProfile)
  1147. this._baseProfile=this._profiles()[this._baseSelect.selectedIndex()];this._baseProfile._loadPromise.then(didLoadBaseSnaphot.bind(this));}}
  1148. function didLoadBaseSnaphot(baseSnapshotProxy)
  1149. {if(this._diffDataGrid.baseSnapshot!==baseSnapshotProxy)
  1150. this._diffDataGrid.setBaseDataSource(baseSnapshotProxy);}},_onSelectedPerspectiveChanged:function(event)
  1151. {this._changePerspective(event.target.selectedIndex);this._onSelectedViewChanged(event);},_onSelectedViewChanged:function(event)
  1152. {},_changePerspective:function(selectedIndex)
  1153. {if(selectedIndex===this._currentPerspectiveIndex)
  1154. return;this._currentPerspectiveIndex=selectedIndex;this._currentPerspective.deactivate(this);var perspective=this._perspectives[selectedIndex];this._currentPerspective=perspective;this._dataGrid=perspective.masterGrid(this);perspective.activate(this);this.refreshVisibleData();if(this._dataGrid)
  1155. this._dataGrid.updateWidths();this._updateDataSourceAndView();if(!this.currentQuery||!this._searchResults)
  1156. return;this.performSearch(this.currentQuery,false);},selectLiveObject:function(perspectiveName,snapshotObjectId)
  1157. {this._changePerspectiveAndWait(perspectiveName,didChangePerspective.bind(this));function didChangePerspective()
  1158. {this._dataGrid.revealObjectByHeapSnapshotId(snapshotObjectId,didRevealObject);}
  1159. function didRevealObject(parentNode,node)
  1160. {if(!node)
  1161. WebInspector.console.error("Cannot find corresponding heap snapshot node");}},_getHoverAnchor:function(target)
  1162. {var span=target.enclosingNodeOrSelfWithNodeName("span");if(!span)
  1163. return;var row=target.enclosingNodeOrSelfWithNodeName("tr");if(!row)
  1164. return;span.node=row._dataGridNode;return span;},_resolveObjectForPopover:function(element,showCallback,objectGroupName)
  1165. {if(!this._profile.target())
  1166. return;if(!element.node)
  1167. return;element.node.queryObjectContent(this._profile.target(),showCallback,objectGroupName);},_updateBaseOptions:function()
  1168. {var list=this._profiles();if(this._baseSelect.size()===list.length)
  1169. return;for(var i=this._baseSelect.size(),n=list.length;i<n;++i){var title=list[i].title;this._baseSelect.createOption(title);}},_updateFilterOptions:function()
  1170. {var list=this._profiles();if(this._filterSelect.size()-1===list.length)
  1171. return;if(!this._filterSelect.size())
  1172. this._filterSelect.createOption(WebInspector.UIString("All objects"));for(var i=this._filterSelect.size()-1,n=list.length;i<n;++i){var title=list[i].title;if(!i)
  1173. title=WebInspector.UIString("Objects allocated before %s",title);else
  1174. title=WebInspector.UIString("Objects allocated between %s and %s",list[i-1].title,title);this._filterSelect.createOption(title);}},_updateControls:function()
  1175. {this._updateBaseOptions();this._updateFilterOptions();},_onReceiveSnapshot:function(event)
  1176. {this._updateControls();},_onProfileHeaderRemoved:function(event)
  1177. {var profile=event.data;if(this._profile===profile){this.detach();this._profile.profileType().removeEventListener(WebInspector.HeapSnapshotProfileType.SnapshotReceived,this._onReceiveSnapshot,this);this._profile.profileType().removeEventListener(WebInspector.ProfileType.Events.RemoveProfileHeader,this._onProfileHeaderRemoved,this);this.dispose();}else{this._updateControls();}},dispose:function()
  1178. {if(this._allocationStackView){this._allocationStackView.clear();this._allocationDataGrid.dispose();}
  1179. if(this._trackingOverviewGrid)
  1180. this._trackingOverviewGrid.dispose();},__proto__:WebInspector.VBox.prototype}
  1181. WebInspector.HeapSnapshotProfileType=function(id,title)
  1182. {WebInspector.ProfileType.call(this,id||WebInspector.HeapSnapshotProfileType.TypeId,title||WebInspector.UIString("Take Heap Snapshot"));WebInspector.targetManager.observeTargets(this);WebInspector.targetManager.addModelListener(WebInspector.HeapProfilerModel,WebInspector.HeapProfilerModel.Events.ResetProfiles,this._resetProfiles,this);WebInspector.targetManager.addModelListener(WebInspector.HeapProfilerModel,WebInspector.HeapProfilerModel.Events.AddHeapSnapshotChunk,this._addHeapSnapshotChunk,this);WebInspector.targetManager.addModelListener(WebInspector.HeapProfilerModel,WebInspector.HeapProfilerModel.Events.ReportHeapSnapshotProgress,this._reportHeapSnapshotProgress,this);}
  1183. WebInspector.HeapSnapshotProfileType.TypeId="HEAP";WebInspector.HeapSnapshotProfileType.SnapshotReceived="SnapshotReceived";WebInspector.HeapSnapshotProfileType.prototype={targetAdded:function(target)
  1184. {target.heapProfilerModel.enable();},targetRemoved:function(target)
  1185. {},fileExtension:function()
  1186. {return".heapsnapshot";},get buttonTooltip()
  1187. {return WebInspector.UIString("Take heap snapshot.");},isInstantProfile:function()
  1188. {return true;},buttonClicked:function()
  1189. {this._takeHeapSnapshot(function(){});WebInspector.userMetrics.ProfilesHeapProfileTaken.record();return false;},get treeItemTitle()
  1190. {return WebInspector.UIString("HEAP SNAPSHOTS");},get description()
  1191. {return WebInspector.UIString("Heap snapshot profiles show memory distribution among your page's JavaScript objects and related DOM nodes.");},createProfileLoadedFromFile:function(title)
  1192. {return new WebInspector.HeapProfileHeader(null,this,title);},_takeHeapSnapshot:function(callback)
  1193. {if(this.profileBeingRecorded())
  1194. return;var target=(WebInspector.context.flavor(WebInspector.Target));var profile=new WebInspector.HeapProfileHeader(target,this);this.setProfileBeingRecorded(profile);this.addProfile(profile);profile.updateStatus(WebInspector.UIString("Snapshotting\u2026"));function didTakeHeapSnapshot(error)
  1195. {var profile=this._profileBeingRecorded;profile.title=WebInspector.UIString("Snapshot %d",profile.uid);profile._finishLoad();this.setProfileBeingRecorded(null);this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProfileComplete,profile);callback();}
  1196. target.heapProfilerAgent().takeHeapSnapshot(true,didTakeHeapSnapshot.bind(this));},_addHeapSnapshotChunk:function(event)
  1197. {if(!this.profileBeingRecorded())
  1198. return;var chunk=(event.data);this.profileBeingRecorded().transferChunk(chunk);},_reportHeapSnapshotProgress:function(event)
  1199. {var profile=this.profileBeingRecorded();if(!profile)
  1200. return;var data=(event.data);profile.updateStatus(WebInspector.UIString("%.0f%",(data.done/data.total)*100),true);if(data.finished)
  1201. profile._prepareToLoad();},_resetProfiles:function()
  1202. {this._reset();},_snapshotReceived:function(profile)
  1203. {if(this._profileBeingRecorded===profile)
  1204. this.setProfileBeingRecorded(null);this.dispatchEventToListeners(WebInspector.HeapSnapshotProfileType.SnapshotReceived,profile);},__proto__:WebInspector.ProfileType.prototype}
  1205. WebInspector.TrackingHeapSnapshotProfileType=function()
  1206. {WebInspector.HeapSnapshotProfileType.call(this,WebInspector.TrackingHeapSnapshotProfileType.TypeId,WebInspector.UIString("Record Heap Allocations"));}
  1207. WebInspector.TrackingHeapSnapshotProfileType.TypeId="HEAP-RECORD";WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate="HeapStatsUpdate";WebInspector.TrackingHeapSnapshotProfileType.TrackingStarted="TrackingStarted";WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped="TrackingStopped";WebInspector.TrackingHeapSnapshotProfileType.prototype={targetAdded:function(target)
  1208. {WebInspector.HeapSnapshotProfileType.prototype.targetAdded.call(this,target);target.heapProfilerModel.addEventListener(WebInspector.HeapProfilerModel.Events.HeapStatsUpdate,this._heapStatsUpdate,this);target.heapProfilerModel.addEventListener(WebInspector.HeapProfilerModel.Events.LastSeenObjectId,this._lastSeenObjectId,this);},targetRemoved:function(target)
  1209. {WebInspector.HeapSnapshotProfileType.prototype.targetRemoved.call(this,target);target.heapProfilerModel.removeEventListener(WebInspector.HeapProfilerModel.Events.HeapStatsUpdate,this._heapStatsUpdate,this);target.heapProfilerModel.removeEventListener(WebInspector.HeapProfilerModel.Events.LastSeenObjectId,this._lastSeenObjectId,this);},_heapStatsUpdate:function(event)
  1210. {if(!this._profileSamples)
  1211. return;var samples=(event.data);var index;for(var i=0;i<samples.length;i+=3){index=samples[i];var size=samples[i+2];this._profileSamples.sizes[index]=size;if(!this._profileSamples.max[index])
  1212. this._profileSamples.max[index]=size;}},_lastSeenObjectId:function(event)
  1213. {var profileSamples=this._profileSamples;if(!profileSamples)
  1214. return;var data=(event.data);var currentIndex=Math.max(profileSamples.ids.length,profileSamples.max.length-1);profileSamples.ids[currentIndex]=data.lastSeenObjectId;if(!profileSamples.max[currentIndex]){profileSamples.max[currentIndex]=0;profileSamples.sizes[currentIndex]=0;}
  1215. profileSamples.timestamps[currentIndex]=data.timestamp;if(profileSamples.totalTime<data.timestamp-profileSamples.timestamps[0])
  1216. profileSamples.totalTime*=2;this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate,this._profileSamples);this._profileBeingRecorded.updateStatus(null,true);},hasTemporaryView:function()
  1217. {return true;},get buttonTooltip()
  1218. {return this._recording?WebInspector.UIString("Stop recording heap profile."):WebInspector.UIString("Start recording heap profile.");},isInstantProfile:function()
  1219. {return false;},buttonClicked:function()
  1220. {return this._toggleRecording();},_startRecordingProfile:function()
  1221. {if(this.profileBeingRecorded())
  1222. return;var recordAllocationStacks=WebInspector.settings.recordAllocationStacks.get();this._addNewProfile(recordAllocationStacks);this.profileBeingRecorded().target().heapProfilerAgent().startTrackingHeapObjects(recordAllocationStacks);},_addNewProfile:function(withAllocationStacks)
  1223. {var target=WebInspector.context.flavor(WebInspector.Target);this.setProfileBeingRecorded(new WebInspector.HeapProfileHeader(target,this,undefined,withAllocationStacks));this._lastSeenIndex=-1;this._profileSamples={'sizes':[],'ids':[],'timestamps':[],'max':[],'totalTime':30000};this._profileBeingRecorded._profileSamples=this._profileSamples;this._recording=true;this.addProfile(this._profileBeingRecorded);this._profileBeingRecorded.updateStatus(WebInspector.UIString("Recording\u2026"));this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.TrackingStarted);},_stopRecordingProfile:function()
  1224. {this._profileBeingRecorded.updateStatus(WebInspector.UIString("Snapshotting\u2026"));function didTakeHeapSnapshot(error)
  1225. {var profile=this.profileBeingRecorded();if(!profile)
  1226. return;profile._finishLoad();this._profileSamples=null;this.setProfileBeingRecorded(null);this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProfileComplete,profile);}
  1227. this._profileBeingRecorded.target().heapProfilerAgent().stopTrackingHeapObjects(true,didTakeHeapSnapshot.bind(this));this._recording=false;this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped);},_toggleRecording:function()
  1228. {if(this._recording)
  1229. this._stopRecordingProfile();else
  1230. this._startRecordingProfile();return this._recording;},get treeItemTitle()
  1231. {return WebInspector.UIString("HEAP TIMELINES");},get description()
  1232. {return WebInspector.UIString("Record JavaScript object allocations over time. Use this profile type to isolate memory leaks.");},_resetProfiles:function()
  1233. {var wasRecording=this._recording;var recordingAllocationStacks=wasRecording&&this.profileBeingRecorded()._hasAllocationStacks;this.setProfileBeingRecorded(null);WebInspector.HeapSnapshotProfileType.prototype._resetProfiles.call(this);this._profileSamples=null;this._lastSeenIndex=-1;if(wasRecording)
  1234. this._addNewProfile(recordingAllocationStacks);},profileBeingRecordedRemoved:function()
  1235. {this._stopRecordingProfile();this._profileSamples=null;},__proto__:WebInspector.HeapSnapshotProfileType.prototype}
  1236. WebInspector.HeapProfileHeader=function(target,type,title,hasAllocationStacks)
  1237. {WebInspector.ProfileHeader.call(this,target,type,title||WebInspector.UIString("Snapshot %d",type.nextProfileUid()));this._hasAllocationStacks=!!hasAllocationStacks;this.maxJSObjectId=-1;this._workerProxy=null;this._receiver=null;this._snapshotProxy=null;this._loadPromise=new Promise(loadResolver.bind(this));this._totalNumberOfChunks=0;this._bufferedWriter=null;function loadResolver(fulfill)
  1238. {this._fulfillLoad=fulfill;}}
  1239. WebInspector.HeapProfileHeader.prototype={createSidebarTreeElement:function(dataDisplayDelegate)
  1240. {return new WebInspector.ProfileSidebarTreeElement(dataDisplayDelegate,this,"heap-snapshot-sidebar-tree-item");},createView:function(dataDisplayDelegate)
  1241. {return new WebInspector.HeapSnapshotView(dataDisplayDelegate,this);},_prepareToLoad:function()
  1242. {console.assert(!this._receiver,"Already loading");this._setupWorker();this.updateStatus(WebInspector.UIString("Loading\u2026"),true);},_finishLoad:function()
  1243. {if(!this._wasDisposed)
  1244. this._receiver.close();if(this._bufferedWriter){this._bufferedWriter.finishWriting(this._didWriteToTempFile.bind(this));this._bufferedWriter=null;}},_didWriteToTempFile:function(tempFile)
  1245. {if(this._wasDisposed){if(tempFile)
  1246. tempFile.remove();return;}
  1247. this._tempFile=tempFile;if(!tempFile)
  1248. this._failedToCreateTempFile=true;if(this._onTempFileReady){this._onTempFileReady();this._onTempFileReady=null;}},_setupWorker:function()
  1249. {function setProfileWait(event)
  1250. {this.updateStatus(null,event.data);}
  1251. console.assert(!this._workerProxy,"HeapSnapshotWorkerProxy already exists");this._workerProxy=new WebInspector.HeapSnapshotWorkerProxy(this._handleWorkerEvent.bind(this));this._workerProxy.addEventListener("wait",setProfileWait,this);this._receiver=this._workerProxy.createLoader(this.uid,this._snapshotReceived.bind(this));},_handleWorkerEvent:function(eventName,data)
  1252. {if(WebInspector.HeapSnapshotProgressEvent.BrokenSnapshot===eventName){var error=(data);WebInspector.console.error(error);return;}
  1253. if(WebInspector.HeapSnapshotProgressEvent.Update!==eventName)
  1254. return;var subtitle=(data);this.updateStatus(subtitle);},dispose:function()
  1255. {if(this._workerProxy)
  1256. this._workerProxy.dispose();this.removeTempFile();this._wasDisposed=true;},_didCompleteSnapshotTransfer:function()
  1257. {if(!this._snapshotProxy)
  1258. return;this.updateStatus(Number.bytesToString(this._snapshotProxy.totalSize),false);},transferChunk:function(chunk)
  1259. {if(!this._bufferedWriter)
  1260. this._bufferedWriter=new WebInspector.DeferredTempFile("heap-profiler",String(this.uid));this._bufferedWriter.write([chunk]);++this._totalNumberOfChunks;this._receiver.write(chunk,function(){});},_snapshotReceived:function(snapshotProxy)
  1261. {if(this._wasDisposed)
  1262. return;this._receiver=null;this._snapshotProxy=snapshotProxy;this.maxJSObjectId=snapshotProxy.maxJSObjectId();this._didCompleteSnapshotTransfer();this._workerProxy.startCheckingForLongRunningCalls();this.notifySnapshotReceived();},notifySnapshotReceived:function()
  1263. {this._fulfillLoad(this._snapshotProxy);this._profileType._snapshotReceived(this);if(this.canSaveToFile())
  1264. this.dispatchEventToListeners(WebInspector.ProfileHeader.Events.ProfileReceived);},_wasShown:function()
  1265. {},canSaveToFile:function()
  1266. {return!this.fromFile()&&!!this._snapshotProxy;},saveToFile:function()
  1267. {var fileOutputStream=new WebInspector.FileOutputStream();function onOpen(accepted)
  1268. {if(!accepted)
  1269. return;if(this._failedToCreateTempFile){WebInspector.console.error("Failed to open temp file with heap snapshot");fileOutputStream.close();}else if(this._tempFile){var delegate=new WebInspector.SaveSnapshotOutputStreamDelegate(this);this._tempFile.writeToOutputSteam(fileOutputStream,delegate);}else{this._onTempFileReady=onOpen.bind(this,accepted);this._updateSaveProgress(0,1);}}
  1270. this._fileName=this._fileName||"Heap-"+new Date().toISO8601Compact()+this._profileType.fileExtension();fileOutputStream.open(this._fileName,onOpen.bind(this));},_updateSaveProgress:function(value,total)
  1271. {var percentValue=((total?(value/total):0)*100).toFixed(0);this.updateStatus(WebInspector.UIString("Saving\u2026 %d\%",percentValue));},loadFromFile:function(file)
  1272. {this.updateStatus(WebInspector.UIString("Loading\u2026"),true);this._setupWorker();var delegate=new WebInspector.HeapSnapshotLoadFromFileDelegate(this);var fileReader=this._createFileReader(file,delegate);fileReader.start(this._receiver);},_createFileReader:function(file,delegate)
  1273. {return new WebInspector.ChunkedFileReader(file,10000000,delegate);},__proto__:WebInspector.ProfileHeader.prototype}
  1274. WebInspector.HeapSnapshotLoadFromFileDelegate=function(snapshotHeader)
  1275. {this._snapshotHeader=snapshotHeader;}
  1276. WebInspector.HeapSnapshotLoadFromFileDelegate.prototype={onTransferStarted:function()
  1277. {},onChunkTransferred:function(reader)
  1278. {},onTransferFinished:function()
  1279. {},onError:function(reader,e)
  1280. {var subtitle;switch(e.target.error.code){case e.target.error.NOT_FOUND_ERR:subtitle=WebInspector.UIString("'%s' not found.",reader.fileName());break;case e.target.error.NOT_READABLE_ERR:subtitle=WebInspector.UIString("'%s' is not readable",reader.fileName());break;case e.target.error.ABORT_ERR:return;default:subtitle=WebInspector.UIString("'%s' error %d",reader.fileName(),e.target.error.code);}
  1281. this._snapshotHeader.updateStatus(subtitle);}}
  1282. WebInspector.SaveSnapshotOutputStreamDelegate=function(profileHeader)
  1283. {this._profileHeader=profileHeader;}
  1284. WebInspector.SaveSnapshotOutputStreamDelegate.prototype={onTransferStarted:function()
  1285. {this._profileHeader._updateSaveProgress(0,1);},onTransferFinished:function()
  1286. {this._profileHeader._didCompleteSnapshotTransfer();},onChunkTransferred:function(reader)
  1287. {this._profileHeader._updateSaveProgress(reader.loadedSize(),reader.fileSize());},onError:function(reader,event)
  1288. {WebInspector.console.error("Failed to read heap snapshot from temp file: "+(event).message);this.onTransferFinished();}}
  1289. WebInspector.HeapTrackingOverviewGrid=function(heapProfileHeader)
  1290. {WebInspector.VBox.call(this);this.element.id="heap-recording-view";this.element.classList.add("heap-tracking-overview");this._overviewContainer=this.element.createChild("div","heap-overview-container");this._overviewGrid=new WebInspector.OverviewGrid("heap-recording");this._overviewGrid.element.classList.add("fill");this._overviewCanvas=this._overviewContainer.createChild("canvas","heap-recording-overview-canvas");this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.HeapTrackingOverviewGrid.OverviewCalculator();this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._profileSamples=heapProfileHeader._profileSamples;if(heapProfileHeader.profileType().profileBeingRecorded()===heapProfileHeader){this._profileType=heapProfileHeader.profileType();this._profileType.addEventListener(WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate,this._onHeapStatsUpdate,this);this._profileType.addEventListener(WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped,this._onStopTracking,this);}
  1291. var timestamps=this._profileSamples.timestamps;var totalTime=this._profileSamples.totalTime;this._windowLeft=0.0;this._windowRight=totalTime&×tamps.length?(timestamps[timestamps.length-1]-timestamps[0])/totalTime:1.0;this._overviewGrid.setWindow(this._windowLeft,this._windowRight);this._yScale=new WebInspector.HeapTrackingOverviewGrid.SmoothScale();this._xScale=new WebInspector.HeapTrackingOverviewGrid.SmoothScale();}
  1292. WebInspector.HeapTrackingOverviewGrid.IdsRangeChanged="IdsRangeChanged";WebInspector.HeapTrackingOverviewGrid.prototype={dispose:function()
  1293. {this._onStopTracking();},_onStopTracking:function()
  1294. {this._profileType.removeEventListener(WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate,this._onHeapStatsUpdate,this);this._profileType.removeEventListener(WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped,this._onStopTracking,this);},_onHeapStatsUpdate:function(event)
  1295. {this._profileSamples=event.data;this._scheduleUpdate();},_drawOverviewCanvas:function(width,height)
  1296. {if(!this._profileSamples)
  1297. return;var profileSamples=this._profileSamples;var sizes=profileSamples.sizes;var topSizes=profileSamples.max;var timestamps=profileSamples.timestamps;var startTime=timestamps[0];var endTime=timestamps[timestamps.length-1];var scaleFactor=this._xScale.nextScale(width/profileSamples.totalTime);var maxSize=0;function aggregateAndCall(sizes,callback)
  1298. {var size=0;var currentX=0;for(var i=1;i<timestamps.length;++i){var x=Math.floor((timestamps[i]-startTime)*scaleFactor);if(x!==currentX){if(size)
  1299. callback(currentX,size);size=0;currentX=x;}
  1300. size+=sizes[i];}
  1301. callback(currentX,size);}
  1302. function maxSizeCallback(x,size)
  1303. {maxSize=Math.max(maxSize,size);}
  1304. aggregateAndCall(sizes,maxSizeCallback);var yScaleFactor=this._yScale.nextScale(maxSize?height/(maxSize*1.1):0.0);this._overviewCanvas.width=width*window.devicePixelRatio;this._overviewCanvas.height=height*window.devicePixelRatio;this._overviewCanvas.style.width=width+"px";this._overviewCanvas.style.height=height+"px";var context=this._overviewCanvas.getContext("2d");context.scale(window.devicePixelRatio,window.devicePixelRatio);context.beginPath();context.lineWidth=2;context.strokeStyle="rgba(192, 192, 192, 0.6)";var currentX=(endTime-startTime)*scaleFactor;context.moveTo(currentX,height-1);context.lineTo(currentX,0);context.stroke();context.closePath();var gridY;var gridValue;var gridLabelHeight=14;if(yScaleFactor){const maxGridValue=(height-gridLabelHeight)/yScaleFactor;gridValue=Math.pow(1024,Math.floor(Math.log(maxGridValue)/Math.log(1024)));gridValue*=Math.pow(10,Math.floor(Math.log(maxGridValue/gridValue)/Math.LN10));if(gridValue*5<=maxGridValue)
  1305. gridValue*=5;gridY=Math.round(height-gridValue*yScaleFactor-0.5)+0.5;context.beginPath();context.lineWidth=1;context.strokeStyle="rgba(0, 0, 0, 0.2)";context.moveTo(0,gridY);context.lineTo(width,gridY);context.stroke();context.closePath();}
  1306. function drawBarCallback(x,size)
  1307. {context.moveTo(x,height-1);context.lineTo(x,Math.round(height-size*yScaleFactor-1));}
  1308. context.beginPath();context.lineWidth=2;context.strokeStyle="rgba(192, 192, 192, 0.6)";aggregateAndCall(topSizes,drawBarCallback);context.stroke();context.closePath();context.beginPath();context.lineWidth=2;context.strokeStyle="rgba(0, 0, 192, 0.8)";aggregateAndCall(sizes,drawBarCallback);context.stroke();context.closePath();if(gridValue){var label=Number.bytesToString(gridValue);var labelPadding=4;var labelX=0;var labelY=gridY-0.5;var labelWidth=2*labelPadding+context.measureText(label).width;context.beginPath();context.textBaseline="bottom";context.font="10px "+window.getComputedStyle(this.element,null).getPropertyValue("font-family");context.fillStyle="rgba(255, 255, 255, 0.75)";context.fillRect(labelX,labelY-gridLabelHeight,labelWidth,gridLabelHeight);context.fillStyle="rgb(64, 64, 64)";context.fillText(label,labelX+labelPadding,labelY);context.fill();context.closePath();}},onResize:function()
  1309. {this._updateOverviewCanvas=true;this._scheduleUpdate();},_onWindowChanged:function()
  1310. {if(!this._updateGridTimerId)
  1311. this._updateGridTimerId=setTimeout(this._updateGrid.bind(this),10);},_scheduleUpdate:function()
  1312. {if(this._updateTimerId)
  1313. return;this._updateTimerId=setTimeout(this.update.bind(this),10);},_updateBoundaries:function()
  1314. {this._windowLeft=this._overviewGrid.windowLeft();this._windowRight=this._overviewGrid.windowRight();this._windowWidth=this._windowRight-this._windowLeft;},update:function()
  1315. {this._updateTimerId=null;if(!this.isShowing())
  1316. return;this._updateBoundaries();this._overviewCalculator._updateBoundaries(this);this._overviewGrid.updateDividers(this._overviewCalculator);this._drawOverviewCanvas(this._overviewContainer.clientWidth,this._overviewContainer.clientHeight-20);},_updateGrid:function()
  1317. {this._updateGridTimerId=0;this._updateBoundaries();var ids=this._profileSamples.ids;var timestamps=this._profileSamples.timestamps;var sizes=this._profileSamples.sizes;var startTime=timestamps[0];var totalTime=this._profileSamples.totalTime;var timeLeft=startTime+totalTime*this._windowLeft;var timeRight=startTime+totalTime*this._windowRight;var minId=0;var maxId=ids[ids.length-1]+1;var size=0;for(var i=0;i<timestamps.length;++i){if(!timestamps[i])
  1318. continue;if(timestamps[i]>timeRight)
  1319. break;maxId=ids[i];if(timestamps[i]<timeLeft){minId=ids[i];continue;}
  1320. size+=sizes[i];}
  1321. this.dispatchEventToListeners(WebInspector.HeapTrackingOverviewGrid.IdsRangeChanged,{minId:minId,maxId:maxId,size:size});},__proto__:WebInspector.VBox.prototype}
  1322. WebInspector.HeapTrackingOverviewGrid.SmoothScale=function()
  1323. {this._lastUpdate=0;this._currentScale=0.0;}
  1324. WebInspector.HeapTrackingOverviewGrid.SmoothScale.prototype={nextScale:function(target){target=target||this._currentScale;if(this._currentScale){var now=Date.now();var timeDeltaMs=now-this._lastUpdate;this._lastUpdate=now;var maxChangePerSec=20;var maxChangePerDelta=Math.pow(maxChangePerSec,timeDeltaMs/1000);var scaleChange=target/this._currentScale;this._currentScale*=Number.constrain(scaleChange,1/maxChangePerDelta,maxChangePerDelta);}else{this._currentScale=target;}
  1325. return this._currentScale;}}
  1326. WebInspector.HeapTrackingOverviewGrid.OverviewCalculator=function()
  1327. {}
  1328. WebInspector.HeapTrackingOverviewGrid.OverviewCalculator.prototype={paddingLeft:function()
  1329. {return 0;},_updateBoundaries:function(chart)
  1330. {this._minimumBoundaries=0;this._maximumBoundaries=chart._profileSamples.totalTime;this._xScaleFactor=chart._overviewContainer.clientWidth/this._maximumBoundaries;},computePosition:function(time)
  1331. {return(time-this._minimumBoundaries)*this._xScaleFactor;},formatTime:function(value,precision)
  1332. {return Number.secondsToString(value/1000,!!precision);},maximumBoundary:function()
  1333. {return this._maximumBoundaries;},minimumBoundary:function()
  1334. {return this._minimumBoundaries;},zeroTime:function()
  1335. {return this._minimumBoundaries;},boundarySpan:function()
  1336. {return this._maximumBoundaries-this._minimumBoundaries;}}
  1337. WebInspector.HeapSnapshotStatisticsView=function()
  1338. {WebInspector.VBox.call(this);this.setMinimumSize(50,25);this._pieChart=new WebInspector.PieChart(150,WebInspector.HeapSnapshotStatisticsView._valueFormatter,true);this._pieChart.element.classList.add("heap-snapshot-stats-pie-chart");this.element.appendChild(this._pieChart.element);this._labels=this.element.createChild("div","heap-snapshot-stats-legend");}
  1339. WebInspector.HeapSnapshotStatisticsView._valueFormatter=function(value)
  1340. {return WebInspector.UIString("%s KB",Number.withThousandsSeparator(Math.round(value/1024)));}
  1341. WebInspector.HeapSnapshotStatisticsView.prototype={setTotal:function(value)
  1342. {this._pieChart.setTotal(value);},addRecord:function(value,name,color)
  1343. {if(color)
  1344. this._pieChart.addSlice(value,color);var node=this._labels.createChild("div");var swatchDiv=node.createChild("div","heap-snapshot-stats-swatch");var nameDiv=node.createChild("div","heap-snapshot-stats-name");var sizeDiv=node.createChild("div","heap-snapshot-stats-size");if(color)
  1345. swatchDiv.style.backgroundColor=color;else
  1346. swatchDiv.classList.add("heap-snapshot-stats-empty-swatch");nameDiv.textContent=name;sizeDiv.textContent=WebInspector.HeapSnapshotStatisticsView._valueFormatter(value);},__proto__:WebInspector.VBox.prototype}
  1347. WebInspector.HeapAllocationStackView=function(target)
  1348. {WebInspector.View.call(this);this._target=target;;this._linkifier=new WebInspector.Linkifier();}
  1349. WebInspector.HeapAllocationStackView.prototype={setAllocatedObject:function(snapshot,snapshotNodeIndex)
  1350. {this.clear();snapshot.allocationStack(snapshotNodeIndex,this._didReceiveAllocationStack.bind(this));},clear:function()
  1351. {this.element.removeChildren();this._linkifier.reset();},_didReceiveAllocationStack:function(frames)
  1352. {if(!frames){var stackDiv=this.element.createChild("div","no-heap-allocation-stack");stackDiv.createTextChild(WebInspector.UIString("Stack was not recorded for this object because it had been allocated before this profile recording started."));return;}
  1353. var stackDiv=this.element.createChild("div","heap-allocation-stack");for(var i=0;i<frames.length;i++){var frame=frames[i];var frameDiv=stackDiv.createChild("div","stack-frame");var name=frameDiv.createChild("div");name.textContent=WebInspector.beautifyFunctionName(frame.functionName);if(frame.scriptId){var urlElement=this._linkifier.linkifyScriptLocation(this._target,String(frame.scriptId),frame.scriptName,frame.line-1,frame.column-1);frameDiv.appendChild(urlElement);}}},__proto__:WebInspector.View.prototype};WebInspector.ProfileLauncherView=function(profilesPanel)
  1354. {WebInspector.VBox.call(this);this._panel=profilesPanel;this.element.classList.add("profile-launcher-view");this.element.classList.add("panel-enabler-view");this._contentElement=this.element.createChild("div","profile-launcher-view-content");this._innerContentElement=this._contentElement.createChild("div");var targetSpan=this._contentElement.createChild("span");var selectTargetText=targetSpan.createChild("span");selectTargetText.textContent=WebInspector.UIString("Target:");var targetsSelect=targetSpan.createChild("select","chrome-select");new WebInspector.TargetsComboBoxController(targetsSelect,targetSpan);this._controlButton=createTextButton("",this._controlButtonClicked.bind(this),"control-profiling");this._contentElement.appendChild(this._controlButton);this._recordButtonEnabled=true;this._loadButton=createTextButton(WebInspector.UIString("Load"),this._loadButtonClicked.bind(this),"load-profile");this._contentElement.appendChild(this._loadButton);WebInspector.targetManager.observeTargets(this);}
  1355. WebInspector.ProfileLauncherView.prototype={searchableView:function()
  1356. {return null;},targetAdded:function(target)
  1357. {this._updateLoadButtonLayout();},targetRemoved:function(target)
  1358. {this._updateLoadButtonLayout();},_updateLoadButtonLayout:function()
  1359. {this._loadButton.classList.toggle("multi-target",WebInspector.targetManager.targets().length>1);},addProfileType:function(profileType)
  1360. {var descriptionElement=this._innerContentElement.createChild("h1");descriptionElement.textContent=profileType.description;var decorationElement=profileType.decorationElement();if(decorationElement)
  1361. this._innerContentElement.appendChild(decorationElement);this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();this._profileTypeId=profileType.id;},_controlButtonClicked:function()
  1362. {this._panel.toggleRecordButton();},_loadButtonClicked:function()
  1363. {this._panel.showLoadFromFileDialog();},_updateControls:function()
  1364. {if(this._isEnabled&&this._recordButtonEnabled)
  1365. this._controlButton.removeAttribute("disabled");else
  1366. this._controlButton.setAttribute("disabled","");this._controlButton.title=this._recordButtonEnabled?"":WebInspector.anotherProfilerActiveLabel();if(this._isInstantProfile){this._controlButton.classList.remove("running");this._controlButton.textContent=WebInspector.UIString("Take Snapshot");}else if(this._isProfiling){this._controlButton.classList.add("running");this._controlButton.textContent=WebInspector.UIString("Stop");}else{this._controlButton.classList.remove("running");this._controlButton.textContent=WebInspector.UIString("Start");}},profileStarted:function()
  1367. {this._isProfiling=true;this._updateControls();},profileFinished:function()
  1368. {this._isProfiling=false;this._updateControls();},updateProfileType:function(profileType,recordButtonEnabled)
  1369. {this._isInstantProfile=profileType.isInstantProfile();this._recordButtonEnabled=recordButtonEnabled;this._isEnabled=profileType.isEnabled();this._profileTypeId=profileType.id;this._updateControls();},__proto__:WebInspector.VBox.prototype}
  1370. WebInspector.MultiProfileLauncherView=function(profilesPanel)
  1371. {WebInspector.ProfileLauncherView.call(this,profilesPanel);WebInspector.settings.selectedProfileType=WebInspector.settings.createSetting("selectedProfileType","CPU");var header=this._innerContentElement.createChild("h1");header.textContent=WebInspector.UIString("Select profiling type");this._profileTypeSelectorForm=this._innerContentElement.createChild("form");this._innerContentElement.createChild("div","flexible-space");this._typeIdToOptionElement={};}
  1372. WebInspector.MultiProfileLauncherView.EventTypes={ProfileTypeSelected:"profile-type-selected"}
  1373. WebInspector.MultiProfileLauncherView.prototype={addProfileType:function(profileType)
  1374. {var labelElement=createRadioLabel("profile-type",profileType.name);this._profileTypeSelectorForm.appendChild(labelElement);var optionElement=labelElement.radioElement;this._typeIdToOptionElement[profileType.id]=optionElement;optionElement._profileType=profileType;optionElement.style.hidden=true;optionElement.addEventListener("change",this._profileTypeChanged.bind(this,profileType),false);var descriptionElement=labelElement.createChild("p");descriptionElement.textContent=profileType.description;var decorationElement=profileType.decorationElement();if(decorationElement)
  1375. labelElement.appendChild(decorationElement);},restoreSelectedProfileType:function()
  1376. {var typeId=WebInspector.settings.selectedProfileType.get();if(!(typeId in this._typeIdToOptionElement))
  1377. typeId=Object.keys(this._typeIdToOptionElement)[0];this._typeIdToOptionElement[typeId].checked=true;var type=this._typeIdToOptionElement[typeId]._profileType;this.dispatchEventToListeners(WebInspector.MultiProfileLauncherView.EventTypes.ProfileTypeSelected,type);},_controlButtonClicked:function()
  1378. {this._panel.toggleRecordButton();},_updateControls:function()
  1379. {WebInspector.ProfileLauncherView.prototype._updateControls.call(this);var items=this._profileTypeSelectorForm.elements;for(var i=0;i<items.length;++i){if(items[i].type==="radio")
  1380. items[i].disabled=this._isProfiling;}},_profileTypeChanged:function(profileType)
  1381. {this.dispatchEventToListeners(WebInspector.MultiProfileLauncherView.EventTypes.ProfileTypeSelected,profileType);this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();this._profileTypeId=profileType.id;this._updateControls();WebInspector.settings.selectedProfileType.set(profileType.id);},profileStarted:function()
  1382. {this._isProfiling=true;this._updateControls();},profileFinished:function()
  1383. {this._isProfiling=false;this._updateControls();},__proto__:WebInspector.ProfileLauncherView.prototype};WebInspector.CanvasProfileView=function(profile)
  1384. {WebInspector.VBox.call(this);this.registerRequiredCSS("profiler/canvasProfiler.css");this.element.classList.add("canvas-profile-view");this._profile=profile;this._traceLogId=profile.traceLogId();this._traceLogPlayer=(profile.traceLogPlayer());this._linkifier=new WebInspector.Linkifier();this._replayInfoSplitView=new WebInspector.SplitView(true,true,"canvasProfileViewReplaySplitViewState",0.34);this._replayInfoSplitView.show(this.element);this._imageSplitView=new WebInspector.SplitView(false,true,"canvasProfileViewSplitViewState",300);this._replayInfoSplitView.setMainView(this._imageSplitView);var replayImageContainerView=new WebInspector.VBoxWithResizeCallback(this._onReplayImageResize.bind(this));replayImageContainerView.setMinimumSize(50,28);this._imageSplitView.setMainView(replayImageContainerView);var replayImageContainer=replayImageContainerView.element;replayImageContainer.id="canvas-replay-image-container";var replayImageParent=replayImageContainer.createChild("div","canvas-replay-image-parent");replayImageParent.createChild("span");this._replayImageElement=replayImageParent.createChild("img");this._debugInfoElement=replayImageContainer.createChild("div","canvas-debug-info hidden");this._spinnerIcon=replayImageContainer.createChild("div","spinner-icon small hidden");var replayLogContainerView=new WebInspector.VBox();replayLogContainerView.setMinimumSize(22,22);this._imageSplitView.setSidebarView(replayLogContainerView);var replayLogContainer=replayLogContainerView.element;var controlsToolbar=new WebInspector.StatusBar(replayLogContainer);var logGridContainer=replayLogContainer.createChild("div","canvas-replay-log");this._createControlButton(controlsToolbar,"first-step-status-bar-item",WebInspector.UIString("First call."),this._onReplayFirstStepClick.bind(this));this._createControlButton(controlsToolbar,"step-out-status-bar-item",WebInspector.UIString("Previous call."),this._onReplayStepClick.bind(this,false));this._createControlButton(controlsToolbar,"step-in-status-bar-item",WebInspector.UIString("Next call."),this._onReplayStepClick.bind(this,true));this._createControlButton(controlsToolbar,"step-backwards-status-bar-item",WebInspector.UIString("Previous drawing call."),this._onReplayDrawingCallClick.bind(this,false));this._createControlButton(controlsToolbar,"step-over-status-bar-item",WebInspector.UIString("Next drawing call."),this._onReplayDrawingCallClick.bind(this,true));this._createControlButton(controlsToolbar,"last-step-status-bar-item",WebInspector.UIString("Last call."),this._onReplayLastStepClick.bind(this));this._replayContextSelector=new WebInspector.StatusBarComboBox(this._onReplayContextChanged.bind(this));this._replayContextSelector.createOption(WebInspector.UIString("<screenshot auto>"),WebInspector.UIString("Show screenshot of the last replayed resource."),"");controlsToolbar.appendStatusBarItem(this._replayContextSelector);this._installReplayInfoSidebarWidgets(replayLogContainer);this._replayStateView=new WebInspector.CanvasReplayStateView(this._traceLogPlayer);this._replayInfoSplitView.setSidebarView(this._replayStateView);this._replayContexts={};var columns=[{title:"#",sortable:false,width:"5%"},{title:WebInspector.UIString("Call"),sortable:false,width:"75%",disclosure:true},{title:WebInspector.UIString("Location"),sortable:false,width:"20%"}];this._logGrid=new WebInspector.DataGrid(columns);this._logGrid.element.classList.add("fill");this._logGrid.show(logGridContainer);this._logGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._replayTraceLog,this);this.element.addEventListener("mousedown",this._onMouseClick.bind(this),true);this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._popoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),this._onHidePopover.bind(this),true);this._popoverHelper.setRemoteObjectFormatter(this._hexNumbersFormatter.bind(this));this._requestTraceLog(0);}
  1385. WebInspector.CanvasProfileView.TraceLogPollingInterval=500;WebInspector.CanvasProfileView.prototype={dispose:function()
  1386. {this._linkifier.reset();},statusBarItems:function()
  1387. {return[];},get profile()
  1388. {return this._profile;},_onReplayImageResize:function()
  1389. {var parent=this._replayImageElement.parentElement;this._replayImageElement.style.maxWidth=(parent.clientWidth-1)+"px";this._replayImageElement.style.maxHeight=(parent.clientHeight-1)+"px";},elementsToRestoreScrollPositionsFor:function()
  1390. {return[this._logGrid.scrollContainer];},_installReplayInfoSidebarWidgets:function(replayLogElement)
  1391. {this._replayInfoResizeWidgetElement=replayLogElement.createChild("div","resizer-widget");this._replayInfoSplitView.addEventListener(WebInspector.SplitView.Events.ShowModeChanged,this._updateReplayInfoResizeWidget,this);this._updateReplayInfoResizeWidget();this._replayInfoSplitView.installResizer(this._replayInfoResizeWidgetElement);},_updateReplayInfoResizeWidget:function()
  1392. {this._replayInfoResizeWidgetElement.classList.toggle("hidden",this._replayInfoSplitView.showMode()!==WebInspector.SplitView.ShowMode.Both);},_onMouseClick:function(event)
  1393. {var resourceLinkElement=event.target.enclosingNodeOrSelfWithClass("canvas-formatted-resource");if(resourceLinkElement){this._replayInfoSplitView.showBoth();this._replayStateView.selectResource(resourceLinkElement.__resourceId);event.consume(true);return;}
  1394. if(event.target.enclosingNodeOrSelfWithClass("webkit-html-resource-link"))
  1395. event.consume(false);},_createControlButton:function(toolbar,className,title,clickCallback)
  1396. {var button=new WebInspector.StatusBarButton(title,className+" canvas-replay-button");toolbar.appendStatusBarItem(button);button.makeLongClickEnabled();button.addEventListener("click",clickCallback,this);button.addEventListener("longClickDown",clickCallback,this);button.addEventListener("longClickPress",clickCallback,this);},_onReplayContextChanged:function()
  1397. {var selectedContextId=this._replayContextSelector.selectedOption().value;function didReceiveResourceState(resourceState)
  1398. {this._enableWaitIcon(false);if(selectedContextId!==this._replayContextSelector.selectedOption().value)
  1399. return;var imageURL=(resourceState&&resourceState.imageURL)||"";this._replayImageElement.src=imageURL;this._replayImageElement.style.visibility=imageURL?"":"hidden";}
  1400. this._enableWaitIcon(true);this._traceLogPlayer.getResourceState(selectedContextId,didReceiveResourceState.bind(this));},_onReplayStepClick:function(forward)
  1401. {var selectedNode=this._logGrid.selectedNode;if(!selectedNode)
  1402. return;var nextNode=selectedNode;do{nextNode=forward?nextNode.traverseNextNode(false):nextNode.traversePreviousNode(false);}while(nextNode&&typeof nextNode.index!=="number");(nextNode||selectedNode).revealAndSelect();},_onReplayDrawingCallClick:function(forward)
  1403. {var selectedNode=this._logGrid.selectedNode;if(!selectedNode)
  1404. return;var nextNode=selectedNode;while(nextNode){var sibling=forward?nextNode.nextSibling:nextNode.previousSibling;if(sibling){nextNode=sibling;if(nextNode.hasChildren||nextNode.call.isDrawingCall)
  1405. break;}else{nextNode=nextNode.parent;if(!forward)
  1406. break;}}
  1407. if(!nextNode&&forward)
  1408. this._onReplayLastStepClick();else
  1409. (nextNode||selectedNode).revealAndSelect();},_onReplayFirstStepClick:function()
  1410. {var firstNode=this._logGrid.rootNode().children[0];if(firstNode)
  1411. firstNode.revealAndSelect();},_onReplayLastStepClick:function()
  1412. {var lastNode=this._logGrid.rootNode().children.peekLast();if(!lastNode)
  1413. return;while(lastNode.expanded){var lastChild=lastNode.children.peekLast();if(!lastChild)
  1414. break;lastNode=lastChild;}
  1415. lastNode.revealAndSelect();},_enableWaitIcon:function(enable)
  1416. {this._spinnerIcon.classList.toggle("hidden",!enable);this._debugInfoElement.classList.toggle("hidden",enable);},_replayTraceLog:function()
  1417. {if(this._pendingReplayTraceLogEvent)
  1418. return;var index=this._selectedCallIndex();if(index===-1||index===this._lastReplayCallIndex)
  1419. return;this._lastReplayCallIndex=index;this._pendingReplayTraceLogEvent=true;function didReplayTraceLog(resourceState,replayTime)
  1420. {delete this._pendingReplayTraceLogEvent;this._enableWaitIcon(false);this._debugInfoElement.textContent=WebInspector.UIString("Replay time: %s",Number.secondsToString(replayTime/1000,true));this._onReplayContextChanged();if(index!==this._selectedCallIndex())
  1421. this._replayTraceLog();}
  1422. this._enableWaitIcon(true);this._traceLogPlayer.replayTraceLog(index,didReplayTraceLog.bind(this));},_requestTraceLog:function(offset)
  1423. {function didReceiveTraceLog(traceLog)
  1424. {this._enableWaitIcon(false);if(!traceLog)
  1425. return;var callNodes=[];var calls=traceLog.calls;var index=traceLog.startOffset;for(var i=0,n=calls.length;i<n;++i)
  1426. callNodes.push(this._createCallNode(index++,calls[i]));var contexts=traceLog.contexts;for(var i=0,n=contexts.length;i<n;++i){var contextId=contexts[i].resourceId||"";var description=contexts[i].description||"";if(this._replayContexts[contextId])
  1427. continue;this._replayContexts[contextId]=true;this._replayContextSelector.createOption(description,WebInspector.UIString("Show screenshot of this context's canvas."),contextId);}
  1428. this._appendCallNodes(callNodes);if(traceLog.alive)
  1429. setTimeout(this._requestTraceLog.bind(this,index),WebInspector.CanvasProfileView.TraceLogPollingInterval);else
  1430. this._flattenSingleFrameNode();this._profile._updateCapturingStatus(traceLog);this._onReplayLastStepClick();}
  1431. this._enableWaitIcon(true);this._traceLogPlayer.getTraceLog(offset,undefined,didReceiveTraceLog.bind(this));},_selectedCallIndex:function()
  1432. {var node=this._logGrid.selectedNode;return node?this._peekLastRecursively(node).index:-1;},_peekLastRecursively:function(node)
  1433. {var lastChild;while((lastChild=node.children.peekLast()))
  1434. node=lastChild;return node;},_appendCallNodes:function(callNodes)
  1435. {var rootNode=this._logGrid.rootNode();var frameNode=rootNode.children.peekLast();if(frameNode&&this._peekLastRecursively(frameNode).call.isFrameEndCall)
  1436. frameNode=null;for(var i=0,n=callNodes.length;i<n;++i){if(!frameNode){var index=rootNode.children.length;var data={};data[0]="";data[1]=WebInspector.UIString("Frame #%d",index+1);data[2]="";frameNode=new WebInspector.DataGridNode(data);frameNode.selectable=true;rootNode.appendChild(frameNode);}
  1437. var nextFrameCallIndex=i+1;while(nextFrameCallIndex<n&&!callNodes[nextFrameCallIndex-1].call.isFrameEndCall)
  1438. ++nextFrameCallIndex;this._appendCallNodesToFrameNode(frameNode,callNodes,i,nextFrameCallIndex);i=nextFrameCallIndex-1;frameNode=null;}},_appendCallNodesToFrameNode:function(frameNode,callNodes,fromIndex,toIndex)
  1439. {var self=this;function appendDrawCallGroup()
  1440. {var index=self._drawCallGroupsCount||0;var data={};data[0]="";data[1]=WebInspector.UIString("Draw call group #%d",index+1);data[2]="";var node=new WebInspector.DataGridNode(data);node.selectable=true;self._drawCallGroupsCount=index+1;frameNode.appendChild(node);return node;}
  1441. function splitDrawCallGroup(drawCallGroup)
  1442. {var splitIndex=0;var splitNode;while((splitNode=drawCallGroup.children[splitIndex])){if(splitNode.call.isDrawingCall)
  1443. break;++splitIndex;}
  1444. var newDrawCallGroup=appendDrawCallGroup();var lastNode;while((lastNode=drawCallGroup.children[splitIndex+1]))
  1445. newDrawCallGroup.appendChild(lastNode);return newDrawCallGroup;}
  1446. var drawCallGroup=frameNode.children.peekLast();var groupHasDrawCall=false;if(drawCallGroup){for(var i=0,n=drawCallGroup.children.length;i<n;++i){if(drawCallGroup.children[i].call.isDrawingCall){groupHasDrawCall=true;break;}}}else
  1447. drawCallGroup=appendDrawCallGroup();for(var i=fromIndex;i<toIndex;++i){var node=callNodes[i];drawCallGroup.appendChild(node);if(node.call.isDrawingCall){if(groupHasDrawCall)
  1448. drawCallGroup=splitDrawCallGroup(drawCallGroup);else
  1449. groupHasDrawCall=true;}}},_createCallNode:function(index,call)
  1450. {var callViewElement=createElement("div");var data={};data[0]=index+1;data[1]=callViewElement;data[2]="";if(call.sourceURL){var lineNumber=Math.max(0,call.lineNumber-1)||0;var columnNumber=Math.max(0,call.columnNumber-1)||0;data[2]=this._linkifier.linkifyScriptLocation(this.profile.target(),null,call.sourceURL,lineNumber,columnNumber);}
  1451. callViewElement.createChild("span","canvas-function-name").textContent=call.functionName||"context."+call.property;if(call.arguments){callViewElement.createTextChild("(");for(var i=0,n=call.arguments.length;i<n;++i){var argument=(call.arguments[i]);if(i)
  1452. callViewElement.createTextChild(", ");var element=WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(argument);element.__argumentIndex=i;callViewElement.appendChild(element);}
  1453. callViewElement.createTextChild(")");}else if(call.value){callViewElement.createTextChild(" = ");callViewElement.appendChild(WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(call.value));}
  1454. if(call.result){callViewElement.createTextChild(" => ");callViewElement.appendChild(WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(call.result));}
  1455. var node=new WebInspector.DataGridNode(data);node.index=index;node.selectable=true;node.call=call;return node;},_popoverAnchor:function(element,event)
  1456. {var argumentElement=element.enclosingNodeOrSelfWithClass("canvas-call-argument");if(!argumentElement||argumentElement.__suppressPopover)
  1457. return;return argumentElement;},_resolveObjectForPopover:function(argumentElement,showCallback,objectGroupName)
  1458. {function showObjectPopover(error,result,resourceState)
  1459. {if(error)
  1460. return;if(!result)
  1461. return;this._popoverAnchorElement=argumentElement.cloneNode(true);this._popoverAnchorElement.classList.add("canvas-popover-anchor");this._popoverAnchorElement.classList.add("source-frame-eval-expression");argumentElement.parentElement.appendChild(this._popoverAnchorElement);var diffLeft=this._popoverAnchorElement.boxInWindow().x-argumentElement.boxInWindow().x;this._popoverAnchorElement.style.left=this._popoverAnchorElement.offsetLeft-diffLeft+"px";showCallback(WebInspector.runtimeModel.createRemoteObject(result),false,this._popoverAnchorElement);}
  1462. var evalResult=argumentElement.__evalResult;if(evalResult)
  1463. showObjectPopover.call(this,null,evalResult);else{var dataGridNode=this._logGrid.dataGridNodeFromNode(argumentElement);if(!dataGridNode||typeof dataGridNode.index!=="number"){this._popoverHelper.hidePopover();return;}
  1464. var callIndex=dataGridNode.index;var argumentIndex=argumentElement.__argumentIndex;if(typeof argumentIndex!=="number")
  1465. argumentIndex=-1;CanvasAgent.evaluateTraceLogCallArgument(this._traceLogId,callIndex,argumentIndex,objectGroupName,showObjectPopover.bind(this));}},_hexNumbersFormatter:function(object)
  1466. {if(object.type==="number"){var str="0000"+Number(object.description).toString(16).toUpperCase();str=str.replace(/^0+(.{4,})$/,"$1");return"0x"+str;}
  1467. return object.description||"";},_onHidePopover:function()
  1468. {if(this._popoverAnchorElement){this._popoverAnchorElement.remove();delete this._popoverAnchorElement;}},_flattenSingleFrameNode:function()
  1469. {var rootNode=this._logGrid.rootNode();if(rootNode.children.length!==1)
  1470. return;var frameNode=rootNode.children[0];while(frameNode.children[0])
  1471. rootNode.appendChild(frameNode.children[0]);rootNode.removeChild(frameNode);},__proto__:WebInspector.VBox.prototype}
  1472. WebInspector.CanvasProfileType=function()
  1473. {WebInspector.ProfileType.call(this,WebInspector.CanvasProfileType.TypeId,WebInspector.UIString("Capture Canvas Frame"));this._recording=false;this._lastProfileHeader=null;this._capturingModeSelector=new WebInspector.StatusBarComboBox(this._dispatchViewUpdatedEvent.bind(this));this._capturingModeSelector.element.title=WebInspector.UIString("Canvas capture mode.");this._capturingModeSelector.createOption(WebInspector.UIString("Single Frame"),WebInspector.UIString("Capture a single canvas frame."),"");this._capturingModeSelector.createOption(WebInspector.UIString("Consecutive Frames"),WebInspector.UIString("Capture consecutive canvas frames."),"1");this._frameOptions={};this._framesWithCanvases={};this._frameSelector=new WebInspector.StatusBarComboBox(this._dispatchViewUpdatedEvent.bind(this));this._frameSelector.element.title=WebInspector.UIString("Frame containing the canvases to capture.");this._frameSelector.element.classList.add("hidden");this._target=null;WebInspector.targetManager.observeTargets(this);this._canvasAgentEnabled=false;this._decorationElement=createElement("div");this._decorationElement.className="profile-canvas-decoration";this._updateDecorationElement();}
  1474. WebInspector.CanvasProfileType.TypeId="CANVAS_PROFILE";WebInspector.CanvasProfileType.prototype={targetAdded:function(target)
  1475. {if(this._target||target!==WebInspector.targetManager.mainTarget())
  1476. return;this._target=target;this._target.resourceTreeModel.frames().forEach(this._addFrame,this);this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded,this._frameAdded,this);this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached,this._frameRemoved,this);new WebInspector.CanvasDispatcher(this._target,this);},targetRemoved:function(target)
  1477. {if(this._target!==target)
  1478. return;this._target=null;this._target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameAdded,this._frameAdded,this);this._target.resourceTreeModel.removeEventListener(WebInspector.ResourceTreeModel.EventTypes.FrameDetached,this._frameRemoved,this);},statusBarItems:function()
  1479. {return[this._capturingModeSelector,this._frameSelector];},get buttonTooltip()
  1480. {if(this._isSingleFrameMode())
  1481. return WebInspector.UIString("Capture next canvas frame.");else
  1482. return this._recording?WebInspector.UIString("Stop capturing canvas frames."):WebInspector.UIString("Start capturing canvas frames.");},buttonClicked:function()
  1483. {if(!this._canvasAgentEnabled)
  1484. return false;if(this._recording){this._recording=false;this._stopFrameCapturing();}else if(this._isSingleFrameMode()){this._recording=false;this._runSingleFrameCapturing();}else{this._recording=true;this._startFrameCapturing();}
  1485. return this._recording;},_runSingleFrameCapturing:function()
  1486. {var frameId=this._selectedFrameId();WebInspector.targetManager.suspendAllTargets();CanvasAgent.captureFrame(frameId,this._didStartCapturingFrame.bind(this,frameId));WebInspector.targetManager.resumeAllTargets();},_startFrameCapturing:function()
  1487. {var frameId=this._selectedFrameId();WebInspector.targetManager.suspendAllTargets();CanvasAgent.startCapturing(frameId,this._didStartCapturingFrame.bind(this,frameId));},_stopFrameCapturing:function()
  1488. {if(!this._lastProfileHeader){WebInspector.targetManager.resumeAllTargets();return;}
  1489. var profileHeader=this._lastProfileHeader;var traceLogId=profileHeader.traceLogId();this._lastProfileHeader=null;function didStopCapturing()
  1490. {profileHeader._updateCapturingStatus();}
  1491. CanvasAgent.stopCapturing(traceLogId,didStopCapturing);WebInspector.targetManager.resumeAllTargets();},_didStartCapturingFrame:function(frameId,error,traceLogId)
  1492. {if(error||this._lastProfileHeader&&this._lastProfileHeader.traceLogId()===traceLogId)
  1493. return;var profileHeader=new WebInspector.CanvasProfileHeader(this._target,this,traceLogId,frameId);this._lastProfileHeader=profileHeader;this.addProfile(profileHeader);profileHeader._updateCapturingStatus();},get treeItemTitle()
  1494. {return WebInspector.UIString("CANVAS PROFILE");},get description()
  1495. {return WebInspector.UIString("Canvas calls instrumentation");},decorationElement:function()
  1496. {return this._decorationElement;},removeProfile:function(profile)
  1497. {WebInspector.ProfileType.prototype.removeProfile.call(this,profile);if(this._recording&&profile===this._lastProfileHeader)
  1498. this._recording=false;},_updateDecorationElement:function(forcePageReload)
  1499. {this._decorationElement.removeChildren();this._decorationElement.createChild("div","warning-icon-small");this._decorationElement.createTextChild(this._canvasAgentEnabled?WebInspector.UIString("Canvas Profiler is enabled."):WebInspector.UIString("Canvas Profiler is disabled."));var button=createTextButton(this._canvasAgentEnabled?WebInspector.UIString("Disable"):WebInspector.UIString("Enable"),this._onProfilerEnableButtonClick.bind(this,!this._canvasAgentEnabled));this._decorationElement.appendChild(button);var target=this._target;if(!target)
  1500. return;function hasUninstrumentedCanvasesCallback(error,result)
  1501. {if(error||result)
  1502. target.resourceTreeModel.reloadPage();}
  1503. if(forcePageReload){if(this._canvasAgentEnabled){target.canvasAgent().hasUninstrumentedCanvases(hasUninstrumentedCanvasesCallback);}else{for(var frameId in this._framesWithCanvases){if(this._framesWithCanvases.hasOwnProperty(frameId)){target.resourceTreeModel.reloadPage();break;}}}}},_onProfilerEnableButtonClick:function(enable)
  1504. {if(this._canvasAgentEnabled===enable)
  1505. return;function callback(error)
  1506. {if(error)
  1507. return;this._canvasAgentEnabled=enable;this._updateDecorationElement(true);this._dispatchViewUpdatedEvent();}
  1508. if(enable)
  1509. CanvasAgent.enable(callback.bind(this));else
  1510. CanvasAgent.disable(callback.bind(this));},_isSingleFrameMode:function()
  1511. {return!this._capturingModeSelector.selectedOption().value;},_frameAdded:function(event)
  1512. {var frame=(event.data);this._addFrame(frame);},_addFrame:function(frame)
  1513. {var frameId=frame.id;var option=createElement("option");option.text=frame.displayName();option.title=frame.url;option.value=frameId;this._frameOptions[frameId]=option;if(this._framesWithCanvases[frameId]){this._frameSelector.addOption(option);this._dispatchViewUpdatedEvent();}},_frameRemoved:function(event)
  1514. {var frame=(event.data);var frameId=frame.id;var option=this._frameOptions[frameId];if(option&&this._framesWithCanvases[frameId]){this._frameSelector.removeOption(option);this._dispatchViewUpdatedEvent();}
  1515. delete this._frameOptions[frameId];delete this._framesWithCanvases[frameId];},_contextCreated:function(frameId)
  1516. {if(this._framesWithCanvases[frameId])
  1517. return;this._framesWithCanvases[frameId]=true;var option=this._frameOptions[frameId];if(option){this._frameSelector.addOption(option);this._dispatchViewUpdatedEvent();}},_traceLogsRemoved:function(frameId,traceLogId)
  1518. {var sidebarElementsToDelete=[];var sidebarElements=((this.treeElement&&this.treeElement.children)||[]);for(var i=0,n=sidebarElements.length;i<n;++i){var header=(sidebarElements[i].profile);if(!header)
  1519. continue;if(frameId&&frameId!==header.frameId())
  1520. continue;if(traceLogId&&traceLogId!==header.traceLogId())
  1521. continue;sidebarElementsToDelete.push(sidebarElements[i]);}
  1522. for(var i=0,n=sidebarElementsToDelete.length;i<n;++i)
  1523. sidebarElementsToDelete[i].ondelete();},_selectedFrameId:function()
  1524. {var option=this._frameSelector.selectedOption();return option?option.value:undefined;},_dispatchViewUpdatedEvent:function()
  1525. {this._frameSelector.element.classList.toggle("hidden",this._frameSelector.size()<=1);this.dispatchEventToListeners(WebInspector.ProfileType.Events.ViewUpdated);},isInstantProfile:function()
  1526. {return this._isSingleFrameMode();},isEnabled:function()
  1527. {return this._canvasAgentEnabled;},__proto__:WebInspector.ProfileType.prototype}
  1528. WebInspector.CanvasDispatcher=function(target,profileType)
  1529. {this._profileType=profileType;target.registerCanvasDispatcher(this);}
  1530. WebInspector.CanvasDispatcher.prototype={contextCreated:function(frameId)
  1531. {this._profileType._contextCreated(frameId);},traceLogsRemoved:function(frameId,traceLogId)
  1532. {this._profileType._traceLogsRemoved(frameId,traceLogId);}}
  1533. WebInspector.CanvasProfileHeader=function(target,type,traceLogId,frameId)
  1534. {WebInspector.ProfileHeader.call(this,target,type,WebInspector.UIString("Trace Log %d",type.nextProfileUid()));this._traceLogId=traceLogId||"";this._frameId=frameId;this._alive=true;this._traceLogSize=0;this._traceLogPlayer=traceLogId?new WebInspector.CanvasTraceLogPlayerProxy(traceLogId):null;}
  1535. WebInspector.CanvasProfileHeader.prototype={traceLogId:function()
  1536. {return this._traceLogId;},traceLogPlayer:function()
  1537. {return this._traceLogPlayer;},frameId:function()
  1538. {return this._frameId;},createSidebarTreeElement:function(panel)
  1539. {return new WebInspector.ProfileSidebarTreeElement(panel,this,"profile-sidebar-tree-item");},createView:function()
  1540. {return new WebInspector.CanvasProfileView(this);},dispose:function()
  1541. {if(this._traceLogPlayer)
  1542. this._traceLogPlayer.dispose();clearTimeout(this._requestStatusTimer);this._alive=false;},_updateCapturingStatus:function(traceLog)
  1543. {if(!this._traceLogId)
  1544. return;if(traceLog){this._alive=traceLog.alive;this._traceLogSize=traceLog.totalAvailableCalls;}
  1545. var subtitle=this._alive?WebInspector.UIString("Capturing\u2026 %d calls",this._traceLogSize):WebInspector.UIString("Captured %d calls",this._traceLogSize);this.updateStatus(subtitle,this._alive);if(this._alive){clearTimeout(this._requestStatusTimer);this._requestStatusTimer=setTimeout(this._requestCapturingStatus.bind(this),WebInspector.CanvasProfileView.TraceLogPollingInterval);}},_requestCapturingStatus:function()
  1546. {function didReceiveTraceLog(traceLog)
  1547. {if(!traceLog)
  1548. return;this._alive=traceLog.alive;this._traceLogSize=traceLog.totalAvailableCalls;this._updateCapturingStatus();}
  1549. this._traceLogPlayer.getTraceLog(0,0,didReceiveTraceLog.bind(this));},__proto__:WebInspector.ProfileHeader.prototype}
  1550. WebInspector.CanvasProfileDataGridHelper={createCallArgumentElement:function(callArgument)
  1551. {if(callArgument.enumName)
  1552. return WebInspector.CanvasProfileDataGridHelper.createEnumValueElement(callArgument.enumName,+callArgument.description);var element=createElement("span");element.className="canvas-call-argument";var description=callArgument.description;if(callArgument.type==="string"){const maxStringLength=150;element.createTextChild("\"");element.createChild("span","canvas-formatted-string").textContent=description.trimMiddle(maxStringLength);element.createTextChild("\"");element.__suppressPopover=(description.length<=maxStringLength&&!/[\r\n]/.test(description));if(!element.__suppressPopover)
  1553. element.__evalResult=WebInspector.runtimeModel.createRemoteObjectFromPrimitiveValue(description);}else{var type=callArgument.subtype||callArgument.type;if(type){element.classList.add("canvas-formatted-"+type);if(["null","undefined","boolean","number"].indexOf(type)>=0)
  1554. element.__suppressPopover=true;}
  1555. element.textContent=description;if(callArgument.remoteObject)
  1556. element.__evalResult=WebInspector.runtimeModel.createRemoteObject(callArgument.remoteObject);}
  1557. if(callArgument.resourceId){element.classList.add("canvas-formatted-resource");element.__resourceId=callArgument.resourceId;}
  1558. return element;},createEnumValueElement:function(enumName,enumValue)
  1559. {var element=createElement("span");element.className="canvas-call-argument canvas-formatted-number";element.textContent=enumName;element.__evalResult=WebInspector.runtimeModel.createRemoteObjectFromPrimitiveValue(enumValue);return element;}}
  1560. WebInspector.CanvasTraceLogPlayerProxy=function(traceLogId)
  1561. {this._traceLogId=traceLogId;this._currentResourceStates={};this._defaultResourceId=null;}
  1562. WebInspector.CanvasTraceLogPlayerProxy.Events={CanvasTraceLogReceived:"CanvasTraceLogReceived",CanvasReplayStateChanged:"CanvasReplayStateChanged",CanvasResourceStateReceived:"CanvasResourceStateReceived",}
  1563. WebInspector.CanvasTraceLogPlayerProxy.prototype={getTraceLog:function(startOffset,maxLength,userCallback)
  1564. {function callback(error,traceLog)
  1565. {if(error||!traceLog){userCallback(null);return;}
  1566. userCallback(traceLog);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasTraceLogReceived,traceLog);}
  1567. CanvasAgent.getTraceLog(this._traceLogId,startOffset,maxLength,callback.bind(this));},dispose:function()
  1568. {this._currentResourceStates={};CanvasAgent.dropTraceLog(this._traceLogId);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);},getResourceState:function(resourceId,userCallback)
  1569. {resourceId=resourceId||this._defaultResourceId;if(!resourceId){userCallback(null);return;}
  1570. var effectiveResourceId=(resourceId);if(this._currentResourceStates[effectiveResourceId]){userCallback(this._currentResourceStates[effectiveResourceId]);return;}
  1571. function callback(error,resourceState)
  1572. {if(error||!resourceState){userCallback(null);return;}
  1573. this._currentResourceStates[effectiveResourceId]=resourceState;userCallback(resourceState);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,resourceState);}
  1574. CanvasAgent.getResourceState(this._traceLogId,effectiveResourceId,callback.bind(this));},replayTraceLog:function(index,userCallback)
  1575. {function callback(error,resourceState,replayTime)
  1576. {this._currentResourceStates={};if(error){userCallback(null,replayTime);}else{this._defaultResourceId=resourceState.id;this._currentResourceStates[resourceState.id]=resourceState;userCallback(resourceState,replayTime);}
  1577. this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);if(!error)
  1578. this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,resourceState);}
  1579. CanvasAgent.replayTraceLog(this._traceLogId,index,callback.bind(this));},clearResourceStates:function()
  1580. {this._currentResourceStates={};this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);},__proto__:WebInspector.Object.prototype};WebInspector.CanvasReplayStateView=function(traceLogPlayer)
  1581. {WebInspector.VBox.call(this);this.registerRequiredCSS("profiler/canvasProfiler.css");this.element.classList.add("canvas-replay-state-view");this._traceLogPlayer=traceLogPlayer;var controlsToolbar=new WebInspector.StatusBar(this.element);this._prevButton=this._createControlButton(controlsToolbar,"play-backwards-status-bar-item",WebInspector.UIString("Previous resource."),this._onResourceNavigationClick.bind(this,false));this._nextButton=this._createControlButton(controlsToolbar,"play-status-bar-item",WebInspector.UIString("Next resource."),this._onResourceNavigationClick.bind(this,true));this._createControlButton(controlsToolbar,"refresh-status-bar-item",WebInspector.UIString("Refresh."),this._onStateRefreshClick.bind(this));this._resourceSelector=new WebInspector.StatusBarComboBox(this._onReplayResourceChanged.bind(this));this._currentOption=this._resourceSelector.createOption(WebInspector.UIString("<auto>"),WebInspector.UIString("Show state of the last replayed resource."),"");controlsToolbar.appendStatusBarItem(this._resourceSelector);this._resourceIdToDescription={};this._gridNodesExpandedState={};this._gridScrollPositions={};this._currentResourceId=null;this._prevOptionsStack=[];this._nextOptionsStack=[];this._highlightedGridNodes=[];var columns=[{title:WebInspector.UIString("Name"),sortable:false,width:"50%",disclosure:true},{title:WebInspector.UIString("Value"),sortable:false,width:"50%"}];this._stateGrid=new WebInspector.DataGrid(columns);this._stateGrid.element.classList.add("fill");this._stateGrid.show(this.element);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged,this._onReplayResourceChanged,this);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasTraceLogReceived,this._onCanvasTraceLogReceived,this);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,this._onCanvasResourceStateReceived,this);this._updateButtonsEnabledState();}
  1582. WebInspector.CanvasReplayStateView.prototype={selectResource:function(resourceId)
  1583. {if(resourceId===this._resourceSelector.selectedOption().value)
  1584. return;var option=this._resourceSelector.selectElement().firstChild;for(var index=0;option;++index,option=option.nextSibling){if(resourceId===option.value){this._resourceSelector.setSelectedIndex(index);this._onReplayResourceChanged();break;}}},_createControlButton:function(toolbar,className,title,clickCallback)
  1585. {var button=new WebInspector.StatusBarButton(title,className);toolbar.appendStatusBarItem(button);button.makeLongClickEnabled();button.addEventListener("click",clickCallback,this);button.addEventListener("longClickDown",clickCallback,this);button.addEventListener("longClickPress",clickCallback,this);return button;},_onResourceNavigationClick:function(forward)
  1586. {var newOption=forward?this._nextOptionsStack.pop():this._prevOptionsStack.pop();if(!newOption)
  1587. return;(forward?this._prevOptionsStack:this._nextOptionsStack).push(this._currentOption);this._isNavigationButton=true;this.selectResource(newOption.value);delete this._isNavigationButton;this._updateButtonsEnabledState();},_onStateRefreshClick:function()
  1588. {this._traceLogPlayer.clearResourceStates();},_updateButtonsEnabledState:function()
  1589. {this._prevButton.setEnabled(this._prevOptionsStack.length>0);this._nextButton.setEnabled(this._nextOptionsStack.length>0);},_updateCurrentOption:function()
  1590. {const maxStackSize=256;var selectedOption=this._resourceSelector.selectedOption();if(this._currentOption===selectedOption)
  1591. return;if(!this._isNavigationButton){this._prevOptionsStack.push(this._currentOption);this._nextOptionsStack=[];if(this._prevOptionsStack.length>maxStackSize)
  1592. this._prevOptionsStack.shift();this._updateButtonsEnabledState();}
  1593. this._currentOption=selectedOption;},_collectResourcesFromTraceLog:function(traceLog)
  1594. {var collectedResources=[];var calls=traceLog.calls;for(var i=0,n=calls.length;i<n;++i){var call=calls[i];var args=call.arguments||[];for(var j=0;j<args.length;++j)
  1595. this._collectResourceFromCallArgument(args[j],collectedResources);this._collectResourceFromCallArgument(call.result,collectedResources);this._collectResourceFromCallArgument(call.value,collectedResources);}
  1596. var contexts=traceLog.contexts;for(var i=0,n=contexts.length;i<n;++i)
  1597. this._collectResourceFromCallArgument(contexts[i],collectedResources);this._addCollectedResourcesToSelector(collectedResources);},_collectResourcesFromResourceState:function(resourceState)
  1598. {var collectedResources=[];this._collectResourceFromResourceStateDescriptors(resourceState.descriptors,collectedResources);this._addCollectedResourcesToSelector(collectedResources);},_collectResourceFromResourceStateDescriptors:function(descriptors,output)
  1599. {if(!descriptors)
  1600. return;for(var i=0,n=descriptors.length;i<n;++i){var descriptor=descriptors[i];this._collectResourceFromCallArgument(descriptor.value,output);this._collectResourceFromResourceStateDescriptors(descriptor.values,output);}},_collectResourceFromCallArgument:function(argument,output)
  1601. {if(!argument)
  1602. return;var resourceId=argument.resourceId;if(!resourceId||this._resourceIdToDescription[resourceId])
  1603. return;this._resourceIdToDescription[resourceId]=argument.description;output.push(argument);},_addCollectedResourcesToSelector:function(collectedResources)
  1604. {if(!collectedResources.length)
  1605. return;function comparator(arg1,arg2)
  1606. {var a=arg1.description;var b=arg2.description;return String.naturalOrderComparator(a,b);}
  1607. collectedResources.sort(comparator);var selectElement=this._resourceSelector.selectElement();var currentOption=selectElement.firstChild;currentOption=currentOption.nextSibling;for(var i=0,n=collectedResources.length;i<n;++i){var argument=collectedResources[i];while(currentOption&&String.naturalOrderComparator(currentOption.text,argument.description)<0)
  1608. currentOption=currentOption.nextSibling;var option=this._resourceSelector.createOption(argument.description,WebInspector.UIString("Show state of this resource."),argument.resourceId);if(currentOption)
  1609. selectElement.insertBefore(option,currentOption);}},_onReplayResourceChanged:function()
  1610. {this._updateCurrentOption();var selectedResourceId=this._resourceSelector.selectedOption().value;function didReceiveResourceState(resourceState)
  1611. {if(selectedResourceId!==this._resourceSelector.selectedOption().value)
  1612. return;this._showResourceState(resourceState);}
  1613. this._traceLogPlayer.getResourceState(selectedResourceId,didReceiveResourceState.bind(this));},_onCanvasTraceLogReceived:function(event)
  1614. {var traceLog=(event.data);console.assert(traceLog);this._collectResourcesFromTraceLog(traceLog);},_onCanvasResourceStateReceived:function(event)
  1615. {var resourceState=(event.data);console.assert(resourceState);this._collectResourcesFromResourceState(resourceState);},_showResourceState:function(resourceState)
  1616. {this._saveExpandedState();this._saveScrollState();var rootNode=this._stateGrid.rootNode();if(!resourceState){this._currentResourceId=null;this._updateDataGridHighlights([]);rootNode.removeChildren();return;}
  1617. var nodesToHighlight=[];var nameToOldGridNodes={};function populateNameToNodesMap(map,node)
  1618. {if(!node)
  1619. return;for(var i=0,child;child=node.children[i];++i){var item={node:child,children:{}};map[child.name]=item;populateNameToNodesMap(item.children,child);}}
  1620. populateNameToNodesMap(nameToOldGridNodes,rootNode);rootNode.removeChildren();function comparator(d1,d2)
  1621. {var hasChildren1=!!d1.values;var hasChildren2=!!d2.values;if(hasChildren1!==hasChildren2)
  1622. return hasChildren1?1:-1;return String.naturalOrderComparator(d1.name,d2.name);}
  1623. function appendResourceStateDescriptors(descriptors,parent,nameToOldChildren)
  1624. {descriptors=descriptors||[];descriptors.sort(comparator);var oldChildren=nameToOldChildren||{};for(var i=0,n=descriptors.length;i<n;++i){var descriptor=descriptors[i];var childNode=this._createDataGridNode(descriptor);parent.appendChild(childNode);var oldChildrenItem=oldChildren[childNode.name]||{};var oldChildNode=oldChildrenItem.node;if(!oldChildNode||oldChildNode.element().textContent!==childNode.element().textContent)
  1625. nodesToHighlight.push(childNode);appendResourceStateDescriptors.call(this,descriptor.values,childNode,oldChildrenItem.children);}}
  1626. appendResourceStateDescriptors.call(this,resourceState.descriptors,rootNode,nameToOldGridNodes);var shouldHighlightChanges=(this._resourceKindId(this._currentResourceId)===this._resourceKindId(resourceState.id));this._currentResourceId=resourceState.id;this._restoreExpandedState();this._updateDataGridHighlights(shouldHighlightChanges?nodesToHighlight:[]);this._restoreScrollState();},_updateDataGridHighlights:function(nodes)
  1627. {for(var i=0,n=this._highlightedGridNodes.length;i<n;++i)
  1628. this._highlightedGridNodes[i].element().classList.remove("canvas-grid-node-highlighted");this._highlightedGridNodes=nodes;for(var i=0,n=this._highlightedGridNodes.length;i<n;++i){var node=this._highlightedGridNodes[i];WebInspector.runCSSAnimationOnce(node.element(),"canvas-grid-node-highlighted");node.reveal();}},_resourceKindId:function(resourceId)
  1629. {var description=(resourceId&&this._resourceIdToDescription[resourceId])||"";return description.replace(/\d+/g,"");},_forEachGridNode:function(callback)
  1630. {function processRecursively(node,key)
  1631. {for(var i=0,child;child=node.children[i];++i){var childKey=key+"#"+child.name;callback(child,childKey);processRecursively(child,childKey);}}
  1632. processRecursively(this._stateGrid.rootNode(),"");},_saveExpandedState:function()
  1633. {if(!this._currentResourceId)
  1634. return;var expandedState={};var key=this._resourceKindId(this._currentResourceId);this._gridNodesExpandedState[key]=expandedState;function callback(node,key)
  1635. {if(node.expanded)
  1636. expandedState[key]=true;}
  1637. this._forEachGridNode(callback);},_restoreExpandedState:function()
  1638. {if(!this._currentResourceId)
  1639. return;var key=this._resourceKindId(this._currentResourceId);var expandedState=this._gridNodesExpandedState[key];if(!expandedState)
  1640. return;function callback(node,key)
  1641. {if(expandedState[key])
  1642. node.expand();}
  1643. this._forEachGridNode(callback);},_saveScrollState:function()
  1644. {if(!this._currentResourceId)
  1645. return;var key=this._resourceKindId(this._currentResourceId);this._gridScrollPositions[key]={scrollTop:this._stateGrid.scrollContainer.scrollTop,scrollLeft:this._stateGrid.scrollContainer.scrollLeft};},_restoreScrollState:function()
  1646. {if(!this._currentResourceId)
  1647. return;var key=this._resourceKindId(this._currentResourceId);var scrollState=this._gridScrollPositions[key];if(!scrollState)
  1648. return;this._stateGrid.scrollContainer.scrollTop=scrollState.scrollTop;this._stateGrid.scrollContainer.scrollLeft=scrollState.scrollLeft;},_createDataGridNode:function(descriptor)
  1649. {var name=descriptor.name;var callArgument=descriptor.value;var valueElement=callArgument?WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(callArgument):"";var nameElement=name;if(typeof descriptor.enumValueForName!=="undefined")
  1650. nameElement=WebInspector.CanvasProfileDataGridHelper.createEnumValueElement(name,+descriptor.enumValueForName);if(descriptor.isArray&&descriptor.values){if(typeof nameElement==="string")
  1651. nameElement+="["+descriptor.values.length+"]";else{var element=createElement("span");element.appendChild(nameElement);element.createTextChild("["+descriptor.values.length+"]");nameElement=element;}}
  1652. var data={};data[0]=nameElement;data[1]=valueElement;var node=new WebInspector.DataGridNode(data);node.selectable=false;node.name=name;return node;},__proto__:WebInspector.VBox.prototype};WebInspector.ProfileTypeRegistry=function()
  1653. {this._profileTypes=[];this.cpuProfileType=new WebInspector.CPUProfileType();this._addProfileType(this.cpuProfileType);this.heapSnapshotProfileType=new WebInspector.HeapSnapshotProfileType();this._addProfileType(this.heapSnapshotProfileType);this.trackingHeapSnapshotProfileType=new WebInspector.TrackingHeapSnapshotProfileType();this._addProfileType(this.trackingHeapSnapshotProfileType);if(!WebInspector.isWorkerFrontend()&&Runtime.experiments.isEnabled("canvasInspection")){this.canvasProfileType=new WebInspector.CanvasProfileType();this._addProfileType(this.canvasProfileType);}}
  1654. WebInspector.ProfileTypeRegistry.prototype={_addProfileType:function(profileType)
  1655. {this._profileTypes.push(profileType);},profileTypes:function()
  1656. {return this._profileTypes;}}
  1657. WebInspector.ProfileTypeRegistry.instance=new WebInspector.ProfileTypeRegistry();;Runtime.cachedResources["profiler/canvasProfiler.css"]="/*\n * Copyright (C) 2012 Google Inc. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n *     * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following disclaimer\n * in the documentation and/or other materials provided with the\n * distribution.\n *     * Neither the name of Google Inc. nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n.canvas-profile-view,\n#canvas-replay-image-container {\n    overflow: hidden;\n}\n\n#canvas-replay-image-container {\n    text-align: center;\n    background-color: black;\n    overflow: hidden;\n    padding: 0;\n    color: white;\n    flex: auto;\n}\n\n.canvas-profile-view .resizer-widget {\n    position: absolute;\n    top: 0;\n    right: 0;\n    height: 24px;\n    width: 16px;\n    background-image: url(Images/statusbarResizerHorizontal.png);\n    background-repeat: no-repeat;\n    background-position: center;\n    z-index: 13;\n}\n\n.canvas-replay-image-parent {\n    position: absolute;\n    top: 5px;\n    left: 5px;\n    right: 5px;\n    bottom: 10px;\n}\n\n.canvas-replay-image-parent > span {\n    display: inline-block;\n    height: 100%;\n    vertical-align: middle;\n}\n\n.canvas-replay-image-parent > img {\n    vertical-align: middle;\n}\n\n.canvas-debug-info {\n    position: absolute;\n    left: 0;\n    right: 0;\n    bottom: 6px;\n}\n\n.canvas-profile-view .spinner-icon {\n    position: absolute;\n    width: 16px;\n    height: 16px;\n    right: 4px;\n    bottom: 4px;\n}\n\n.canvas-replay-log {\n    flex: auto;\n    position: relative;\n}\n\n.canvas-replay-log .data-grid {\n    border: none;\n}\n\n.canvas-replay-button {\n    min-width: 32px;\n}\n\n.canvas-popover-anchor {\n    position: absolute;\n    text-indent: 0;\n    padding: 0;\n    margin: 0;\n}\n.data-grid:focus tr.selected .canvas-popover-anchor {\n    background-color: #aaa !important;\n}\n\n.canvas-function-name {\n}\n\n.canvas-formatted-resource {\n    color: rgb(33%, 33%, 33%);\n}\n.canvas-formatted-resource.canvas-popover-anchor,\n.canvas-formatted-resource:hover {\n    color: rgb(38, 38, 38);\n    text-decoration: underline;\n    cursor: pointer;\n}\n\n/* Keep in sync with \"console-formatted-*\" CSS styles. */\n.canvas-formatted-object,\n.canvas-formatted-node,\n.canvas-formatted-array {\n    color: #222;\n}\n.canvas-formatted-number {\n    color: rgb(28, 0, 207);\n}\n.canvas-formatted-string,\n.canvas-formatted-regexp {\n    color: rgb(196, 26, 22);\n}\n.canvas-formatted-null,\n.canvas-formatted-undefined {\n    color: rgb(128, 128, 128);\n}\n.data-grid:focus tr.selected .canvas-call-argument,\n.data-grid:focus tr.selected .canvas-formatted-string {\n    color: inherit !important;\n}\n\n.canvas-replay-state-view .data-grid {\n    top: 23px;\n}\n\n.canvas-replay-state-view .data-grid .data-container tr:nth-child(odd).canvas-grid-node-highlighted {\n    -webkit-animation: fadeout-odd 2s 0s;\n    background-color: rgb(255, 255, 175);\n}\n\n.canvas-replay-state-view .data-grid .data-container tr:nth-child(even).canvas-grid-node-highlighted {\n    -webkit-animation: fadeout-even 2s 0s;\n    background-color: rgb(235, 235, 120);\n}\n\n@-webkit-keyframes fadeout-odd {\n    from { background-color: rgb(255, 255, 25); }\n    to { background-color: rgb(255, 255, 175); }\n}\n\n@-webkit-keyframes fadeout-even {\n    from { background-color: rgb(255, 255, 25); }\n    to { background-color: rgb(235, 235, 120); }\n}\n\n.canvas-profile-view .status-bar {\n    background-color: #eee;\n    border-bottom: 1px solid #ccc;\n}\n\n/*# sourceURL=profiler/canvasProfiler.css */";Runtime.cachedResources["profiler/heapProfiler.css"]="/*\n * Copyright (C) 2009 Google Inc. All rights reserved.\n * Copyright (C) 2010 Apple Inc. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n *     * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n *     * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following disclaimer\n * in the documentation and/or other materials provided with the\n * distribution.\n *     * Neither the name of Google Inc. nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n.heap-snapshot-sidebar-tree-item .icon {\n    content: url(Images/profileIcon.png);\n}\n\n.heap-snapshot-sidebar-tree-item.small .icon {\n    content: url(Images/profileSmallIcon.png);\n}\n\n.heap-snapshot-view {\n    overflow: hidden;\n}\n\n.heap-snapshot-view .data-grid {\n    border: none;\n}\n\n.heap-snapshot-view .data-grid tr:empty {\n    height: 16px;\n    visibility: hidden;\n}\n\n.heap-snapshot-view .data-grid span.percent-column {\n    width: 32px;\n}\n\n.heap-snapshot-view .console-formatted-object,\n.console-formatted-node {\n    display: inline;\n    position: static;\n}\n\n.detached-dom-tree-node {\n    background-color: #FF9999;\n}\n\n.heap-snapshot-view .console-formatted-string {\n    white-space: nowrap;\n}\n\n.heap-snapshot-view tr:not(.selected) .console-formatted-id {\n    color: grey;\n}\n\n.heap-snapshot-view .data-grid {\n    flex: auto;\n}\n\n.heap-snapshot-view .heap-tracking-overview {\n    flex: 0 0 80px;\n    height: 80px;\n}\n\n.heap-snapshot-view .retaining-paths-view {\n    overflow: hidden;\n}\n\n.heap-snapshot-view .heap-snapshot-view-resizer {\n    background-image: url(Images/statusbarResizerVertical.png);\n    background-color: #eee;\n    border-bottom: 1px solid rgb(179, 179, 179);\n    background-repeat: no-repeat;\n    background-position: right center, center;\n    flex: 0 0 21px;\n}\n\n.heap-snapshot-view .heap-snapshot-view-resizer .title > span {\n    display: inline-block;\n    padding-top: 3px;\n    vertical-align: middle;\n    margin-left: 4px;\n    margin-right: 8px;\n}\n\n.heap-snapshot-view .heap-snapshot-view-resizer * {\n    pointer-events: none;\n}\n\n.heap-snapshot-view .heap-object-details-header {\n    background-color: #eee;\n}\n\n.heap-snapshot-view tr:not(.selected) td.object-column span.highlight {\n    background-color: rgb(255, 255, 200);\n}\n\n.heap-snapshot-view td.object-column span.grayed {\n    color: gray;\n}\n\n.cycled-ancessor-node {\n    opacity: 0.6;\n}\n\n#heap-recording-view .heap-snapshot-view {\n    top: 80px;\n}\n\n.heap-overview-container {\n    overflow: hidden;\n    position: absolute;\n    top: 0;\n    width: 100%;\n    height: 80px;\n}\n\n#heap-recording-overview-grid .resources-dividers-label-bar {\n    pointer-events: auto;\n}\n\n#heap-recording-overview-container {\n    border-bottom: 1px solid rgba(0, 0, 0, 0.3);\n}\n\n.heap-recording-overview-canvas {\n    position: absolute;\n    top: 20px;\n    left: 0;\n    right: 0;\n    bottom: 0;\n}\n\n.heap-snapshot-stats-pie-chart {\n    margin: 12px 30px;\n}\n\n.heap-snapshot-stats-legend {\n    margin-left: 24px;\n}\n\n.heap-snapshot-stats-legend > div {\n    margin-top: 1px;\n    width: 170px;\n}\n\n.heap-snapshot-stats-swatch {\n    display: inline-block;\n    width: 10px;\n    height: 10px;\n    border: 1px solid rgba(100, 100, 100, 0.3);\n}\n\n.heap-snapshot-stats-swatch.heap-snapshot-stats-empty-swatch {\n    border: none;\n}\n\n.heap-snapshot-stats-name,\n.heap-snapshot-stats-size {\n    display: inline-block;\n    margin-left: 6px;\n}\n\n.heap-snapshot-stats-size {\n    float: right;\n    text-align: right;\n}\n\n.heap-allocation-stack .stack-frame {\n    display: flex;\n    justify-content: space-between;\n    border-bottom: 1px solid rgb(240, 240, 240);\n    padding: 2px;\n}\n\n.heap-allocation-stack .stack-frame a {\n    color: rgb(33%, 33%, 33%);\n}\n\n.no-heap-allocation-stack {\n    padding: 5px;\n}\n\n/*# sourceURL=profiler/heapProfiler.css */";Runtime.cachedResources["profiler/profilesPanel.css"]="/*\n * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.\n * Copyright (C) 2009 Anthony Ricaud <rik@webkit.org>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1.  Redistributions of source code must retain the above copyright\n *     notice, this list of conditions and the following disclaimer.\n * 2.  Redistributions in binary form must reproduce the above copyright\n *     notice, this list of conditions and the following disclaimer in the\n *     documentation and/or other materials provided with the distribution.\n * 3.  Neither the name of Apple Computer, Inc. (\"Apple\") nor the names of\n *     its contributors may be used to endorse or promote products derived\n *     from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/* Profiler Style */\n\n#profile-views {\n    flex: auto;\n    position: relative;\n}\n\n.profile-view .data-grid table.data {\n    background: white;\n}\n\n.profile-view .data-grid tr:not(.selected) .highlight {\n    background-color: rgb(255, 230, 179);\n}\n\n.profile-view .data-grid tr:hover td:not(.bottom-filler-td) {\n    background-color: rgba(0, 0, 0, 0.1);\n}\n\n.profile-view .data-grid td.numeric-column {\n    text-align: right;\n}\n\n.profile-view .data-grid div.profile-multiple-values {\n    float: right;\n}\n\n.profile-view .data-grid span.percent-column {\n    color: #999;\n    width: 48px;\n    display: inline-block;\n}\n\n.profile-view .data-grid tr.selected span {\n    color: inherit;\n}\n\n.profiles-status-bar {\n    display: flex;\n    background-color: #eee;\n    flex: 0 0 25px;\n    flex-direction: row;\n    border-bottom: 1px solid rgb(202, 202, 202);\n}\n\n.profile-launcher-view-tree-item > .icon {\n    width: 4px !important;\n    visibility: hidden;\n}\n\n.profiles-sidebar-tree-box {\n    overflow: auto;\n    flex: auto;\n}\n\n.profiles-sidebar-tree-box > ol {\n    overflow: auto;\n    flex: auto;\n}\n\n.profile-sidebar-tree-item .icon {\n    content: url(Images/profileIcon.png);\n}\n\n.profile-sidebar-tree-item.small .icon {\n    content: url(Images/profileSmallIcon.png);\n}\n\n.profile-group-sidebar-tree-item .icon {\n    content: url(Images/profileGroupIcon.png);\n}\n\n.sidebar-tree-item .title-container > .save-link {\n    text-decoration: underline;\n    margin-left: auto;\n    display: none;\n}\n\n.sidebar-tree-item.selected .title-container > .save-link {\n    display: block;\n}\n\n.cpu-profile-view {\n    display: none;\n    overflow: hidden;\n}\n\n.cpu-profile-view.visible {\n    display: flex;\n}\n\n.cpu-profile-view .data-grid {\n    border: none;\n    flex: auto;\n}\n\n.cpu-profile-view .data-grid th.self-column,\n.cpu-profile-view .data-grid th.total-column {\n    text-align: center;\n}\n\n.profile-node-file {\n    float: right;\n    color: gray;\n}\n\n.profile-warn-marker {\n    background-image: url(Images/statusbarButtonGlyphs.png);\n    background-size: 320px 144px;\n    background-position: -202px -107px;\n    width: 10px;\n    height: 10px;\n    vertical-align: -1px;\n    margin-right: 2px;\n    display: inline-block;\n}\n\n.data-grid tr.selected .profile-node-file {\n    color: rgb(33%, 33%, 33%);\n}\n\n.data-grid:focus tr.selected .profile-node-file {\n    color: white;\n}\n\n.profile-launcher-view-content {\n    padding: 0 16px;\n    text-align: left;\n}\n\n.control-profiling {\n    -webkit-align-self: flex-start;\n    margin-right: 50px;\n}\n\n.profile-launcher-view-content h1 {\n    padding: 15px 0 10px;\n}\n\n.panel-enabler-view.profile-launcher-view form {\n    padding: 0;\n    font-size: 13px;\n    width: 100%;\n}\n\n.panel-enabler-view.profile-launcher-view label {\n    margin: 0;\n}\n\n.profile-launcher-view-content p {\n    color: grey;\n    margin-top: 1px;\n    margin-left: 22px;\n}\n\n.profile-launcher-view-content button.running {\n    color: hsl(0, 100%, 58%);\n}\n\n.profile-launcher-view-content button.running:hover {\n    color: hsl(0, 100%, 42%);\n}\n\nbody.inactive .profile-launcher-view-content button.running:not(.status-bar-item) {\n    color: rgb(220, 130, 130);\n}\n\n.highlighted-row {\n    -webkit-animation: row_highlight 2s 0s;\n}\n\n@-webkit-keyframes row_highlight {\n    from {background-color: rgba(255, 255, 120, 1); }\n    to { background-color: rgba(255, 255, 120, 0); }\n}\n\n.profile-canvas-decoration .warning-icon-small {\n    margin-right: 4px;\n}\n\n.profile-canvas-decoration {\n    color: red;\n    margin: -14px 0 13px 22px;\n    padding-left: 14px;\n}\n\n.profile-canvas-decoration button {\n    margin: 0 0 0 10px !important;\n}\n\n.profiles.panel select.chrome-select {\n    font-size: 12px;\n    width: 150px;\n    margin-left: 10px;\n    margin-right: 10px;\n}\n\nbutton.load-profile {\n    margin-left: 20px;\n}\n\nbutton.load-profile.multi-target {\n    display: block;\n    margin-top: 14px;\n    margin-left: 0;\n}\n\n.cpu-profile-flame-chart-overview-container {\n    overflow: hidden;\n    position: absolute;\n    top: 0;\n    width: 100%;\n    height: 80px;\n}\n\n#cpu-profile-flame-chart-overview-container {\n    border-bottom: 1px solid rgba(0, 0, 0, 0.3);\n}\n\n.cpu-profile-flame-chart-overview-canvas {\n    position: absolute;\n    top: 20px;\n    left: 0;\n    right: 0;\n    bottom: 0;\n}\n\n#cpu-profile-flame-chart-overview-grid .resources-dividers-label-bar {\n    pointer-events: auto;\n}\n\n.cpu-profile-flame-chart-overview-pane {\n    flex: 0 0 80px !important;\n}\n\n/*# sourceURL=profiler/profilesPanel.css */";